HOME PAGE | DOWNLOAD | TUTORIALS | XtraReports
Devexpress

Sunday, July 22, 2012

How to: Display a Custom String in the Filter Panel when a View's Data is not Filtered

In the following example the ColumnView.CustomFilterDisplayText event is handled to display the "No Filter" string in the filter panel when a View's data is not filtered.

If a View's data is not filtered the event's Value parameter is set to null. In this instance, the custom display text that needs to be displayed in the filter panel is assigned to this parameter. If the View is filtered, the Value parameter specifies a valid CriteriaOperator object, which represents the current filter criteria. In this instance, the example illustrates the textual representation of the current filter is assigned to the Value parameter. Alternatively, you can check the current CriteriaOperator object, to provide custom display text depending upon the current filter.

The result for a sample grid control is displayed below:

C#

private void gridView1_CustomFilterDisplayText(object sender,

    DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs e) {

    if (e.Value == null) {

        e.Value = "No Filter";               

    }

    else {

        e.Value = e.Value.ToString();

    }

    e.Handled = true;           

}

 

VB

Private Sub GridView1_CustomFilterDisplayText(ByVal sender As System.Object, _
ByVal e As DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs) _
Handles GridView1.CustomFilterDisplayText
    If e.Value Is Nothing Then
        e.Value = "No Filter"
    Else
        e.Value = e.Value.ToString()
    End If
    e.Handled = True
End Sub

 

No comments:

Post a Comment