DataViewBase.SearchControl Property
Gets or sets the search control. This is a dependency property.
Namespace: DevExpress.Xpf.Grid
Assembly:
DevExpress.Xpf.Grid.v20.2.Core.dll
NuGet Packages:
DevExpress.WindowsDesktop.Wpf.Grid.Core, DevExpress.Wpf.Grid.Core
Declaration
[Browsable(false)]
public SearchControl SearchControl { get; set; }
<Browsable(False)>
Public Property SearchControl As SearchControl
Property Value
Handle the SearchControl property to set a custom SearchControl instead of the built-in Search Panel to provide the Grid with the ability to search against multiple columns.
If you use a standalone SearchControl associated with a grid, set DataViewBase properties (ShowSearchPanelFindButton, SearchPanelFindMode, etc.) to configure the SearchControl.
Example
This example shows how to set a custom SearchControl instead of the built-in Search Panel to provide the Grid with the ability to search against multiple columns.
View Example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace DXGrid_Custom_SearchControl {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
gridControl1.ItemsSource = new nwindDataSetTableAdapters.CustomersTableAdapter().GetData();
}
}
}
<Window x:Class="DXGrid_Custom_SearchControl.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
Title="MainWindow" Height="420" Width="550" xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<dxg:GridSearchControl View="{Binding ElementName=tableView1}"/>
<dxg:GridControl Grid.Row="1" AutoGenerateColumns="None" Name="gridControl1">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="ContactName" />
<dxg:GridColumn FieldName="CompanyName" />
<dxg:GridColumn FieldName="City" />
<dxg:GridColumn FieldName="Country" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView Name="tableView1" ShowSearchPanelMode="Never"/>
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</Window>
<Application x:Class="DXGrid_Custom_SearchControl.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Navigation
Imports System.Windows.Shapes
Namespace DXGrid_Custom_SearchControl
''' <summary>
''' Interaction logic for MainWindow.xaml
''' </summary>
Partial Public Class MainWindow
Inherits Window
Public Sub New()
InitializeComponent()
gridControl1.ItemsSource = (New nwindDataSetTableAdapters.CustomersTableAdapter()).GetData()
End Sub
End Class
End Namespace
Imports System
Imports System.Collections.Generic
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Windows
Namespace DXGrid_Custom_SearchControl
''' <summary>
''' Interaction logic for App.xaml
''' </summary>
Partial Public Class App
Inherits Application
End Class
End Namespace
See Also