Find Panel
- 3 minutes to read
Overview
The tree list can display a find panel that enables users to search for keywords in visible columns.
Note
Run the XtraTreeList demo to see the find panel in action.
Keyboard Operations
Filter and Search Modes
- Press Ctrl+F to open the find panel.
- Press Esc once to clear the panel, and press it again to close it.
- Press the Down Arrow key to move focus from the panel to the grid.
Search Mode Only
- To go to the next result, press one of the following shortcuts:
- F3
- Enter (only if the find panel is focused)
- To go to the previous result, press one of the following shortcuts:
- Shift+F3
- Alt/Ctrl/Shift+Enter (only if the find panel is focused)
Options
The TreeList.OptionsFind property provides access to options specific to the find panel.
Behavior: Search or Filter
The TreeList.OptionsFind.Behavior property specifies how to show search results:
Filter — hides records that do not match the query and (optionally) highlights results within the tree list.
Search — highlights results in the tree list and on the scrollbar.
If this property is set to Default, the behavior depends on the static (Shared in VB) WindowsFormsSettings.FindPanelBehavior property. If FindPanelBehavior is also set to Default, the Filter mode is applied.
Highlight Results
To specify whether search queries are highlighted, use the TreeList.OptionsFind.HighlightFindResults property.
Panel Visibility
- TreeList.ShowFindPanel() — opens and focuses the panel. To open and focus the panel when the control is displayed for the first time, use the BeginInvoke method to call this method asynchronously (see an example).
- TreeList.HideFindPanel() — closes the panel.
- TreeList.OptionsFind.AllowFindPanel — gets or sets whether users can invoke the panel with Ctrl+F.
- TreeList.OptionsFind.AlwaysVisible — gets or sets whether the panel is shown/hidden with Ctrl+F, or always visible.
Specify search queries in code
- TreeList.ApplyFindFilter(System.String) — enters the specified query in the find panel and applies it.
- TreeList.ClearFindFilter — discards the query and clears the find panel.
- TreeList.CustomRowFilter — specifies node visibility regardless of the currently applied filter.
- TreeList.OptionsFind.FindFilterColumns — names of columns in which to search the keywords. Note that the find panel searches for keywords in visible columns only (see Visible).
Automatically Apply Search Queries
After a user types in the search box, the search starts automatically depending on the underlying data source. You can use use the TreeList.OptionsFind.FindMode property to specify this behavior. If the search begins automatically after a query is entered, the TreeList.OptionsFind.FindDelay property specifies the delay before the search is initiated.
Search Syntax
Search syntax can vary depending on the TreeList.OptionsFind.ParserKind and TreeList.OptionsFind.Condition properties. See the following help topic for more information: Find Panel Syntax.
Parse Search Query
If standard search syntax does not fit your needs or you need to highlight search results in a custom manner, you can handle the TreeList.ParseFindPanelText event. The event allows you to create a filter condition based on the query and specify how to highlight results in the control.
Expand Nodes on Search
The TreeListOptionsFind.ExpandNodesOnSearch property specifies whether to expand tree list nodes if their child nodes contain the search string.
Operation Buttons
Use the following properties to show/hide buttons.
Filter and Search Modes
- TreeList.OptionsFind.ShowCloseButton - the X button closes the panel.
Filter Mode Only
- TreeList.OptionsFind.ShowFindButton - the Find button applies the query.
- TreeList.OptionsFind.ShowClearButton - the Clear button.
Search Mode Only
- TreeList.OptionsFind.ShowSearchNavButtons - the Previous and Next buttons allow users to navigate between search results.