Click here to Skip to main content
15,892,809 members
Articles / Web Development / ASP.NET

A Filter Dialog for a DataGridView

Rate me:
Please Sign up or sign in to vote.
4.04/5 (9 votes)
28 Sep 20067 min read 114K   4.5K   75  
This is a dialog window that allows filtering a DataGridView. It can build filters with any depth of parentheses.
'' FILENAME:        GenericExpression.vb
'' NAMESPACE:       PI.Dialogs.Filter
'' APPLICATION:     N/A
'' CREATED BY:      Luke Berg
'' CREATED:         8-8-06
'' REVISED BY:      Luke Berg   
'' REVISED:         8-29-06
'' DESCRIPTION:     A class representing an expression (operand and criter) of a filter item, from which
''                  all expressions inherit.


Public Class GenericExpression

    Private _ReadableOperand As String ' A readable version of the operand
    Private _ReadableCriteria As String ' A readable version of the criteria
    Protected _Filter As String ' The filter for this filter Item

    Protected field As String ' The field the expression is filtering on.

    '' Indicates that the filter has changed
    Public Event FilterChanged(ByVal sender As Object, ByVal e As EventArgs)

    ''' <summary>
    '''  A readable version of the criteria (If the criteria were '*test*' the readable
    '''  criteria would be test)
    ''' </summary>
    Public Property ReadableCriteria() As String
        Get
            Return _ReadableCriteria
        End Get
        Set(ByVal value As String)
            _ReadableCriteria = value
        End Set
    End Property

    ''' <summary>
    '''  A readable version of the operand (instead of = it would be 'equal to')
    ''' </summary>
    Public Property ReadableOperand() As String
        Get
            Return _ReadableOperand
        End Get
        Set(ByVal value As String)
            _ReadableOperand = value
        End Set
    End Property

    ''' <summary>
    '''  A method that allows child classes to raise its event
    ''' </summary>
    ''' <remarks></remarks>
    Protected Sub RaiseFilterChanged()
        RaiseEvent FilterChanged(Me, New EventArgs)
    End Sub

    ''' <summary>
    '''  The filterstring that the filterItem of which this expression is a part of represents.
    ''' </summary>
    Public ReadOnly Property Filter() As String
        Get
            Return _Filter
        End Get
    End Property
End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions