GrapeCity MultiRow Windows Forms Documentation
Filtering Method (IFilteringCell)
Example 


The IFilteringCell's edited formatted value.
The target cell's value.
The target cell's parent row index.
Filters the specified cell with the IFilteringCell's edited formatted value.
Syntax
Function Filtering( _
   ByVal editedFormattedValue As Object, _
   ByVal targetCellValue As Object, _
   ByVal targetRowIndex As Integer _
) As Boolean
Dim instance As IFilteringCell
Dim editedFormattedValue As Object
Dim targetCellValue As Object
Dim targetRowIndex As Integer
Dim value As Boolean
 
value = instance.Filtering(editedFormattedValue, targetCellValue, targetRowIndex)

Parameters

editedFormattedValue
The IFilteringCell's edited formatted value.
targetCellValue
The target cell's value.
targetRowIndex
The target cell's parent row index.

Return Value

true if targetCellValue is filtered; otherwise, false.
Example
The following code example shows how to customize a filtering cell using this interface. This code example is part of a larger example provided for the FilteringTextBoxCell class.
private Cell CreateComboBoxFilterCell()
        {
            return new MyFileringComboBoxCell();
        }

        class MyFileringComboBoxCell : ComboBoxCell, IFilteringCell
        {
            public MyFileringComboBoxCell()
            {
                this.Items.Add("");
                this.Items.Add("Leader");
                this.Items.Add("Developer");
                this.Items.Add("Tester");
            }

            public bool Filtering(object editedFormattedValue, object targetCellValue, int targetRowIndex)
            {
                if (object.Equals(editedFormattedValue, string.Empty) || object.Equals(editedFormattedValue, null))
                {
                    return false;
                }
                return !object.Equals(editedFormattedValue, targetCellValue);
            }

            public int FilteringCellIndex
            {
                get { return 1; }
            }
        }

        private Cell CreateCheckBoxFilterCell()
        {
            return new MyFilteringCheckBoxCell();
        }

        class MyFilteringCheckBoxCell : CheckBoxCell, IFilteringCell
        {
            public MyFilteringCheckBoxCell()
            {
                this.ThreeState = true;
            }

            public bool Filtering(object editedFormattedValue, object targetCellValue, int targetRowIndex)
            {
                if (object.Equals(editedFormattedValue, CheckState.Indeterminate))
                {
                    return false;
                }
                if (object.Equals(targetCellValue, null) || object.Equals(targetCellValue, false))
                {
                    return !object.Equals(editedFormattedValue, CheckState.Unchecked);
                }
                if (object.Equals(targetCellValue, true))
                {
                    return !object.Equals(editedFormattedValue, CheckState.Checked);
                }
                return false;
            }

            public int FilteringCellIndex
            {
                get { return 2; }
            }
        }
Private Function CreateComboBoxFilterCell() As Cell
        Return New MyFileringComboBoxCell()
    End Function

    Private Class MyFileringComboBoxCell
        Inherits ComboBoxCell
        Implements IFilteringCell
        Public Sub New()
            Me.Items.Add("")
            Me.Items.Add("Leader")
            Me.Items.Add("Developer")
            Me.Items.Add("Tester")
        End Sub

        Public Function Filtering(ByVal editedFormattedValue As Object, ByVal targetCellValue As Object, ByVal targetRowIndex As Integer) As Boolean Implements IFilteringCell.Filtering
            If Object.Equals(editedFormattedValue, String.Empty) OrElse Object.Equals(editedFormattedValue, Nothing) Then
                Return False
            End If
            Return Not Object.Equals(editedFormattedValue, targetCellValue)
        End Function

        Public ReadOnly Property FilteringCellIndex() As Integer Implements IFilteringCell.FilteringCellIndex
            Get
                Return 1
            End Get
        End Property
    End Class

    Private Function CreateCheckBoxFilterCell() As Cell
        Return New MyFilteringCheckBoxCell()
    End Function

    Private Class MyFilteringCheckBoxCell
        Inherits CheckBoxCell
        Implements IFilteringCell
        Public Sub New()
            Me.ThreeState = True
        End Sub

        Public Function Filtering(ByVal editedFormattedValue As Object, ByVal targetCellValue As Object, ByVal targetRowIndex As Integer) As Boolean Implements IFilteringCell.Filtering
            If Object.Equals(editedFormattedValue, CheckState.Indeterminate) Then
                Return False
            End If
            If Object.Equals(targetCellValue, Nothing) OrElse Object.Equals(targetCellValue, False) Then
                Return Not Object.Equals(editedFormattedValue, CheckState.Unchecked)
            End If
            If Object.Equals(targetCellValue, True) Then
                Return Not Object.Equals(editedFormattedValue, CheckState.Checked)
            End If
            Return False
        End Function

        Public ReadOnly Property FilteringCellIndex() As Integer Implements IFilteringCell.FilteringCellIndex
            Get
                Return 2
            End Get
        End Property
    End Class
Requirements

Target Platforms: 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

See Also

Reference

IFilteringCell Interface
IFilteringCell Members

 

 


Copyright © GrapeCity, inc. All rights reserved.