Back to Devexpress

SearchControl Class

windowsforms-devexpress-dot-xtraeditors-b39becf4.md

latest7.6 KB
Original Source

SearchControl Class

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

Declaration

csharp
[DXLicenseWinFormsEditors]
public class SearchControl :
    MRUEdit,
    ISearchControl
vb
<DXLicenseWinFormsEditors>
Public Class SearchControl
    Inherits MRUEdit
    Implements ISearchControl

The following members return SearchControl objects:

Remarks

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.

csharp
searchControl1.Client = listBoxControl1;
vb
searchControl1.Client = listBoxControl1

Apply Queries

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.

MRU Items

Use the SearchControl.Properties.Items property to access the collection of most recently used (MRU) items.

csharp
// Clears all MRU items.
searchControl1.Properties.Items.Clear();
vb
' Clears all MRU items.
searchControl1.Properties.Items.Clear()

Related event handlers:

Buttons

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.

Prompt

The control displays a prompt when no query is entered in the search box. Use the NullValuePrompt property to specify the prompt.

csharp
textEdit1.Properties.NullValuePrompt = "Enter text to search...";
vb
textEdit1.Properties.NullValuePrompt = "Enter text to search..."

Multi-Column Clients

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.

Example

The code below shows how to search in the Ship Country column only.

csharp
using DevExpress.XtraEditors;

private void searchControl1_QueryIsSearchColumn(object sender, QueryIsSearchColumnEventArgs args) {
    if (args.FieldName != "ShipCountry")
        args.IsSearchColumn = false;    
}
vb
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

Embed the Control in a Bar or Ribbon

You can place a SearchControl on a bar or ribbon. See the following topic for more information: RepositoryItemSearchControl.

Search Syntax

See the following topic for more information about search syntax: Find Panel Syntax.

Implements

IXtraResizableControl

Inheritance

Show 15 items

Object MarshalByRefObject Component Control DevExpress.XtraEditors.XtraControl ControlBase BaseControl BaseEdit TextEdit ButtonEdit PopupBaseEdit PopupBaseAutoSearchEdit ComboBoxEdit MRUEdit SearchControl

See Also

SearchControl Members

RepositoryItemSearchControl

GridControl

TreeList

VGridControl

PropertyGridControl

ListBoxControl

ImageListBoxControl

CheckedListBoxControl

ResourcesCheckedListBoxControl

NavBarControl

AccordionControl

BaseGallery

DevExpress.XtraEditors Namespace