'宣言 Public Property FilterOperatorDefaultValue As Nullable(Of ComparisonOperator)
public Nullable<ComparisonOperator> FilterOperatorDefaultValue {get; set;}
FilterOperatorDefaultValue プロパティはデフォルト フィルター演算子を指定します。フィルター セルのフィルター演算子の選択の UI は、この値に初期化します。フィルター セルの演算子ドロップダウンを使用することによって、ユーザーが別の演算子に変更できます。
どの演算子が演算子ドロップダウン リストに表示されるかを制御するには、FilterOperatorDropDownItems プロパティを設定します。演算子 UI を非表示するのに、FilterDropDownItems を None に設定します。
FilterUIType プロパティを FilterRecord に設定し、AllowRecordFiltering プロパティを True に設定することによって、フィルター レコード機能を有効にする必要がある点に注意してください。このプロパティは、フィルター レコードの各フィルター セルの演算子 UI の最初の値を管理します。FilterUIType が LabelIcons に設定される場合は、このプロパティに影響しません。
Imports Infragistics.Windows Imports Infragistics.Windows.Controls Imports Infragistics.Windows.Editors Imports Infragistics.Windows.DataPresenter Imports Infragistics.Windows.DataPresenter.Events Private Sub Dp_FieldLayoutInitialized(ByVal sender As Object, ByVal e As FieldLayoutInitializedEventArgs) ' Enable the filter-record. e.FieldLayout.FieldSettings.AllowRecordFiltering = True ' FilterStringComparisonType controls whether to perform case-sensitive or ' case-insensitive string comparisons for filtering purposes. e.FieldLayout.FieldSettings.FilterStringComparisonType = FieldSortComparisonType.CaseInsensitive ' The following for loop sets FilterOperatorDefaultValue, FilterOperatorDropDownItems ' and FilterOperandUIType properties on each field based on the field's data type. Dim field As Field For Each field In e.FieldLayout.Fields Dim dataType As Type = field.DataType If dataType Is GetType(String) Then ' For string fields, pre-select StartsWith operator. field.Settings.FilterOperatorDefaultValue = ComparisonOperator.StartsWith ' For operator drop-down, limit the available options to the following. field.Settings.FilterOperatorDropDownItems = ComparisonOperatorFlags.Equals _ Or ComparisonOperatorFlags.StartsWith _ Or ComparisonOperatorFlags.Contains _ Or ComparisonOperatorFlags.Like ' For the operand input, use a text-box. e.FieldLayout.FieldSettings.FilterOperandUIType = FilterOperandUIType.TextBox ElseIf Utilities.IsNumericType(dataType) OrElse dataType Is GetType(DateTime) Then ' For numeric and date fields, pre-select Equals operator. field.Settings.FilterOperatorDefaultValue = ComparisonOperator.Equals ' For operator drop-down, limit the available options to the following. field.Settings.FilterOperatorDropDownItems = ComparisonOperatorFlags.Equals _ Or ComparisonOperatorFlags.LessThan _ Or ComparisonOperatorFlags.LessThanOrEqualsTo _ Or ComparisonOperatorFlags.GreaterThan _ Or ComparisonOperatorFlags.GreaterThanOrEqualsTo ' For the operand input, use the same editor as rest of the cells in the field ' are using. By default numeric field cells use numeric editor and date field ' cells use date-time editor. e.FieldLayout.FieldSettings.FilterOperandUIType = FilterOperandUIType.UseFieldEditor ElseIf dataType Is GetType(Boolean) Then ' For boolean fields, set the default operator to Equals. field.Settings.FilterOperatorDefaultValue = ComparisonOperator.Equals ' Also just allow Equals operator. This will effectively hide the operator ' drop-down. field.Settings.FilterOperatorDropDownItems = ComparisonOperatorFlags.Equals ' For the operand input, use drop-down list. field.Settings.FilterOperandUIType = FilterOperandUIType.DropDownList End If Next End Sub
using Infragistics.Windows; using Infragistics.Windows.Controls; using Infragistics.Windows.Editors; using Infragistics.Windows.DataPresenter; using Infragistics.Windows.DataPresenter.Events; private void dp_FieldLayoutInitialized( object sender, FieldLayoutInitializedEventArgs e ) { // Enable the filter-record. e.FieldLayout.FieldSettings.AllowRecordFiltering = true; // FilterStringComparisonType controls whether to perform case-sensitive or // case-insensitive string comparisons for filtering purposes. e.FieldLayout.FieldSettings.FilterStringComparisonType = FieldSortComparisonType.CaseInsensitive; // The following for loop sets FilterOperatorDefaultValue, FilterOperatorDropDownItems // and FilterOperandUIType properties on each field based on the field's data type. foreach ( Field field in e.FieldLayout.Fields ) { Type dataType = field.DataType; if ( typeof( string ) == dataType ) { // For string fields, pre-select StartsWith operator. field.Settings.FilterOperatorDefaultValue = ComparisonOperator.StartsWith; // For operator drop-down, limit the available options to the following. field.Settings.FilterOperatorDropDownItems = ComparisonOperatorFlags.Equals | ComparisonOperatorFlags.StartsWith | ComparisonOperatorFlags.Contains | ComparisonOperatorFlags.Like; // For the operand input, use a text-box. e.FieldLayout.FieldSettings.FilterOperandUIType = FilterOperandUIType.TextBox; } else if ( Utilities.IsNumericType( dataType ) || typeof( DateTime ) == dataType ) { // For numeric and date fields, pre-select Equals operator. field.Settings.FilterOperatorDefaultValue = ComparisonOperator.Equals; // For operator drop-down, limit the available options to the following. field.Settings.FilterOperatorDropDownItems = ComparisonOperatorFlags.Equals | ComparisonOperatorFlags.LessThan | ComparisonOperatorFlags.LessThanOrEqualsTo | ComparisonOperatorFlags.GreaterThan | ComparisonOperatorFlags.GreaterThanOrEqualsTo; // For the operand input, use the same editor as rest of the cells in the field // are using. By default numeric field cells use numeric editor and date field // cells use date-time editor. e.FieldLayout.FieldSettings.FilterOperandUIType = FilterOperandUIType.UseFieldEditor; } else if ( typeof( bool ) == dataType ) { // For boolean fields, set the default operator to Equals. field.Settings.FilterOperatorDefaultValue = ComparisonOperator.Equals; // Also just allow Equals operator. This will effectively hide the operator // drop-down. field.Settings.FilterOperatorDropDownItems = ComparisonOperatorFlags.Equals; // For the operand input, use drop-down list. field.Settings.FilterOperandUIType = FilterOperandUIType.DropDownList; } } }