GrapeCity MultiRow Windows Forms Documentation
FilteringCellIndex Property (IFilteringCell)
Example 


Gets the cell index in the row of the cell that needs to be filtered.
Syntax
ReadOnly Property FilteringCellIndex As Integer
Dim instance As IFilteringCell
Dim value As Integer
 
value = instance.FilteringCellIndex
int FilteringCellIndex {get;}

Property Value

A System.Int32 value that represents the cell index in the row of the cell that needs to be filtered.
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.