下面的示例代码实现了自定义筛选,并禁用 UnitPrice 列的 自定义筛选对话框 对话框。
当 筛选下拉列表 中的 (Custom) 项被选中时,一个自定义筛选标准将被创建并应用于视图。 这些标准选择“UnitPrice”列中包含小于 10 或大于 30 取值的记录。
C# | 复制代码 |
---|---|
using DevExpress.XtraGrid.Views.Grid; using DevExpress.XtraGrid.Columns; private void gridView1_CustomFilterDialog(object sender, CustomFilterDialogEventArgs e) { if (e.Column.FieldName == "UnitPrice") { e.FilterInfo = new ColumnFilterInfo( ColumnFilterType.Custom, null, "[UnitPrice] < 10 Or [UnitPrice] > 30", "[Unit Price] < '10' Or [Unit Price] > '30'"); e.Handled = true; } } |
Visual Basic | 复制代码 |
---|---|
Imports DevExpress.XtraGrid.Views.Grid Imports DevExpress.XtraGrid.Columns Private Sub GridView1_CustomFilterDialog(ByVal sender As System.Object, _ ByVal e As CustomFilterDialogEventArgs) Handles GridView1.CustomFilterDialog If e.Column.FieldName = "UnitPrice" Then e.FilterInfo = New ColumnFilterInfo( _ ColumnFilterType.Custom, Nothing, "[UnitPrice] < 10 Or [UnitPrice] > 30", _ "[Unit Price] < '10' Or [Unit Price] > '30'") e.Handled = True End If End Sub |