windowsforms-devexpress-dot-xtraeditors-b39becf4.md
A control that allows a user to search and filter data in the attached control.
Namespace : DevExpress.XtraEditors
Assembly : DevExpress.XtraEditors.v25.2.dll
NuGet Package : DevExpress.Win.Navigation
[DXLicenseWinFormsEditors]
public class SearchControl :
MRUEdit,
ISearchControl
<DXLicenseWinFormsEditors>
Public Class SearchControl
Inherits MRUEdit
Implements ISearchControl
The following members return SearchControl objects:
The SearchControl allows a user to enter a query in the search box to filter data in the attached control. To specify the attached control, use the SearchControl.Client property.
searchControl1.Client = listBoxControl1;
searchControl1.Client = listBoxControl1
The control automatically applies a query after a delay. Use the FindDelay property to specify the delay. You can also disable the AllowAutoApply property to apply search queries only when a user presses the Enter key.
Use the SearchControl.Properties.Items property to access the collection of most recently used (MRU) items.
// Clears all MRU items.
searchControl1.Properties.Items.Clear();
' Clears all MRU items.
searchControl1.Properties.Items.Clear()
Related event handlers:
The control can display the Search and Clear buttons. Use the ShowDefaultButtonsMode property to specify when these buttons are displayed:
AutoChangeSearchToClear and Default - the Search button changes to the Clear button if a query is entered in the search box.
AutoShowClear - the Clear button is displayed if a query is entered in the search box.
Always - the Search and Clear buttons are always displayed.
The ShowMRUButton property specifies whether to show the drop-down button that invokes a list of recently used search requests. You can also use the Buttons collection to add custom buttons to the control.
The control displays a prompt when no query is entered in the search box. Use the NullValuePrompt property to specify the prompt.
textEdit1.Properties.NullValuePrompt = "Enter text to search...";
textEdit1.Properties.NullValuePrompt = "Enter text to search..."
If the client control displays data in multiple columns, the SearchControl searches in all of them. You can handle the QueryIsSearchColumn event to prevent a search in a specific column.
The code below shows how to search in the Ship Country column only.
using DevExpress.XtraEditors;
private void searchControl1_QueryIsSearchColumn(object sender, QueryIsSearchColumnEventArgs args) {
if (args.FieldName != "ShipCountry")
args.IsSearchColumn = false;
}
Imports DevExpress.XtraEditors
Private Sub SearchControl1_QueryIsSearchColumn(sender As Object, args As QueryIsSearchColumnEventArgs) _
Handles SearchControl1.QueryIsSearchColumn
If args.FieldName <> "ShipCountry" Then
args.IsSearchColumn = False
End If
End Sub
You can place a SearchControl on a bar or ribbon. See the following topic for more information: RepositoryItemSearchControl.
See the following topic for more information about search syntax: Find Panel Syntax.
Show 15 items
Object MarshalByRefObject Component Control DevExpress.XtraEditors.XtraControl ControlBase BaseControl BaseEdit TextEdit ButtonEdit PopupBaseEdit PopupBaseAutoSearchEdit ComboBoxEdit MRUEdit SearchControl
See Also