'Declaration Public Enum FilterComparisionOperator Inherits System.Enum
public enum FilterComparisionOperator : System.Enum
Member | Description |
---|---|
Contains | Tests to see if the cell value contains the operand. |
Custom | Used for creating custom filters. This is used when deriving a class from FilterCondition and implementing custom logic for filter evaluation by overriding the MeetsCriteria method of in the derived class. Default implementation of MeetsCriteria always returns true for Custom filter comparision operator and thus it's necessary to derive from FilterCondition and override the MeetsCriteria for custom filters. |
DoesNotContain | Complement of Contains. |
DoesNotEndWith | Complement of EndsWith. |
DoesNotMatch | Complement of Match. |
DoesNotStartWith | Complement of StartsWith. |
EndsWith | Tests to see if the cell value ends with the operand. |
Equals | Tests for two values being equal. |
GreaterThan | Tests for the column's value being greater than the value. |
GreaterThanOrEqualTo | Tests for the column's value being greater than or equal to the value. |
In | Tests to see if the value is one of specified values. |
LessThan | Tests for the column's value being less than the value. |
LessThanOrEqualTo | Tests for the column's value being less than or equal to the value. |
Like | Will do a wildcard comparision of the column's value to the comparision value taking comparision value as the string with wild cards. |
Match | Will do a regular expression comparision of the column's value to the comparision value taking comparision value as regular expression string. |
NotEquals | Tests for two values being not equal. |
NotIn | Tests to see if the value is not one of specified values. |
NotLike | Complement of Like. |
StartsWith | Tests to see if the cell value starts with the operand. |
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" ); } }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2