'宣言 Public Enum FilterComparisionOperator Inherits System.Enum
public enum FilterComparisionOperator : System.Enum
メンバ | 解説 |
---|---|
Contains | セルの値がオペランドを含むかどうかをテストします。 |
Custom | カスタム フィルターの作成に使用します。これは、FilterCondition からクラスを派生し、派生クラス内の MeetsCriteria メソッドをオーバーライドしてフィルター評価用のカスタム ロジックを実装するときに使用します。MeetsCriteria のデフォルトの実装では、Custom のフィルター比較演算子に対して常に True が返されます。したがって、FilterCondition から派生し、MeetsCriteria をカスタム フィルター用にオーバーライドする必要があります。 |
DoesNotContain | Contains の逆。 |
DoesNotEndWith | EndsWith の逆。 |
DoesNotMatch | Matchの逆。 |
DoesNotStartWith | StartsWith の逆。 |
EndsWith | セルの値がオペランドで終わるかどうかをテストします。 |
Equals | 2つの値が等しいかどうかをテストします。 |
GreaterThan | 列の値が特定の値より大きいかどうかをテストします。 |
GreaterThanOrEqualTo | 列の値が特定の値以上かどうかをテストします。 |
In | 値が指定した値かどうかを確認します。 |
LessThan | 列の値が特定の値より小さいかどうかをテストします。 |
LessThanOrEqualTo | 列の値が特定の値以下かどうかをテストします。 |
Like | 比較値 (ワイルドカードを含む文字列) に対して列の値のワイルドカード比較を実行します。 |
Match | 列の値と値を文字列比較。 |
NotEquals | 2 つの値が等しいかどうかをテストします。 |
NotIn | 値が指定した値ではないかどうかを確認します。 |
NotLike | Like の逆。 |
StartsWith | セルの値がオペランドで始まるかどうかをテストします。 |
Imports Infragistics.Shared Imports Infragistics.Win Imports Infragistics.Win.UltraWinGrid ' Derive a class from FilterCondition to create a custom filter criteria. ' Mark the class Serializable. This is only necessary if you intend to serialize ' the filter condition object (Load and Save layouts with this filter applied). <Serializable()> _ Private Class OddEvenFilterCondition Inherits FilterCondition ' This is only necessary if you intend to serialize the filter condition object. ' (Load and Save layouts with this filter applied). Protected Sub New( _ ByVal info As System.Runtime.Serialization.SerializationInfo, _ ByVal context As System.Runtime.Serialization.StreamingContext) MyBase.New(info, context) End Sub Sub New(ByVal column As UltraGridColumn, ByVal odd As Boolean) MyBase.New(column, FilterComparisionOperator.Custom, Nothing) ' Store any necessary information to the CompareValue property because the ' base class serializes the CompareValue. This is only necessary if you ' intend to serialize filter condition object (Load and Save layouts with ' this filter applied) and don't want to write your own code for serializing ' the information. Me.CompareValue = odd End Sub ' Override MeetsCriteria method and write your own code for filtering the row. Public Overrides Function MeetsCriteria(ByVal row As UltraGridRow) As Boolean ' Following code filters out the rows with odd or even values depending on ' the whether compare value is set to true or false. ' Following code filters out the rows with odd or even values depending on ' the whether compare value is set to true or false. Dim cellVal As Object = row.GetCellValue(Me.Column) Try Dim val As Integer = Convert.ToInt32(cellVal) Dim odd As Boolean = DirectCast(Me.CompareValue, Boolean) If odd Then Return 1 = val Mod 2 Else Return 0 = val Mod 2 End If Catch e As Exception ' Cell value was either DBNull or something that could not be converted ' to int. Return true to pass the row so that it's visible. (You could ' return false here if you want such rows to get hidden). End Try End Function End Class Private Sub UltraGrid1_BeforeRowFilterDropDown(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeRowFilterDropDownEventArgs) Handles UltraGrid1.BeforeRowFilterDropDown If e.Column.Key = "Col1" Then ' Clear all items from the filter drop down except (All) which allows the user ' to clear the filters on the column. Dim i As Integer For i = e.ValueList.ValueListItems.Count - 1 To 0 Step -1 ' Remove Custom option from the filter drop down. If Not e.ValueList.ValueListItems(i).DisplayText.Equals("(All)") Then e.ValueList.ValueListItems.RemoveAt(i) End If Next ' Add two items one that filters in rows that are odd and one that filters in rows ' that are even. e.ValueList.ValueListItems.Add(New OddEvenFilterCondition(e.Column, True), "Odd") e.ValueList.ValueListItems.Add(New OddEvenFilterCondition(e.Column, False), "Even") End If End Sub
using Infragistics.Shared; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System.Diagnostics; // Derive a class from FilterCondition to create a custom filter criteria. // Mark the class Serializable. This is only necessary if you intend to serialize // the filter condition object (Load and Save layouts with this filter applied). [ Serializable() ] private class OddEvenFilterCondition : FilterCondition { // This is only necessary if you intend to serialize the filter condition object. // (Load and Save layouts with this filter applied). /// <summary> /// Constructor for serialization. /// </summary> /// <param name="info"></param> /// <param name="context"></param> protected OddEvenFilterCondition( System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context ) : base( info, context ) { } /// <summary> /// Constructor. /// </summary> /// <param name="column"></param> /// <param name="odd"></param> internal OddEvenFilterCondition( UltraGridColumn column, bool odd ) : base( column, FilterComparisionOperator.Custom, null ) { // Store any necessary information to the CompareValue property because the // base class serializes the CompareValue. This is only necessary if you // intend to serialize filter condition object (Load and Save layouts with // this filter applied) and don't want to write your own code for serializing // the information. this.CompareValue = odd; } // Override MeetsCriteria method and write your own code for filtering the row. public override bool MeetsCriteria( UltraGridRow row ) { // Following code filters out the rows with odd or even values depending on // the whether compare value is set to true or false. object cellVal = row.GetCellValue( this.Column ); try { int val = Convert.ToInt32( cellVal ); bool odd = (bool)this.CompareValue; if ( odd ) return 1 == val % 2; else return 0 == val % 2; } catch ( Exception ) { // Cell value was either DBNull or something that could not be converted // to int. Return true to pass the row so that it's visible. (You could // return false here if you want such rows to get hidden). return true; } } } private void ultraGrid1_BeforeRowFilterDropDown(object sender, Infragistics.Win.UltraWinGrid.BeforeRowFilterDropDownEventArgs e) { if ( e.Column.Key == "Col1" ) { // Clear all items from the filter drop down except (All) which allows the user // to clear the filters on the column. for ( int i = e.ValueList.ValueListItems.Count - 1; i >= 0; i-- ) { // Remove Custom option from the filter drop down. if ( ! e.ValueList.ValueListItems[i].DisplayText.Equals( "(All)" ) ) e.ValueList.ValueListItems.RemoveAt( i ); } // Add two items one that filters in rows that are odd and one that filters in rows // that are even. e.ValueList.ValueListItems.Add( new OddEvenFilterCondition( e.Column, true ), "Odd" ); e.ValueList.ValueListItems.Add( new OddEvenFilterCondition( e.Column, false ), "Even" ); } }