ColumnView.CustomDrawFilterPanel Event

Enables you to paint the filter panel manually.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v20.1.dll

Declaration

[DXCategory("CustomDraw")]
public event CustomDrawObjectEventHandler CustomDrawFilterPanel
<DXCategory("CustomDraw")>
Public Event CustomDrawFilterPanel As CustomDrawObjectEventHandler

Event Data

The CustomDrawFilterPanel event's data class is CustomDrawObjectEventArgs. The following properties provide information specific to this event:

Property Description
Appearance Gets the painted element's appearance settings. Inherited from CustomDrawEventArgs.
Bounds Returns a value specifying limits for the drawing area. Inherited from CustomDrawEventArgs.
Cache Provides methods to paint on drawing surfaces in GDI+ and DirectX modes. See DirectX hardware acceleration to learn more. Inherited from CustomDrawEventArgs.
Graphics A GDI+ drawing surface. Use the CustomDrawEventArgs.Cache property instead if you enable the DirectX hardware acceleration. Inherited from CustomDrawEventArgs.
Handled Gets or sets a value specifying whether an event was handled and that the default element painting is therefore not required. Inherited from CustomDrawEventArgs.
Info Gets an object containing information about the painted element.
Painter Gets the painter object that provides the default element painting mechanism.

Remarks

The appearance of the filter panel can be customized via the ColumnViewAppearances.FilterPanel object. Handle the CustomDrawFilterPanel event to get complete control over the panel's painting. See the Custom Painting Basics and Custom Painting Scenarios topics for information on using custom draw events.

The CustomDrawFilterPanel event is raised before the filter panel is repainted. Handle this event to paint the panel manually or to paint additional elements on it. Information about the filter panel and its inner elements can be obtained via the CustomDrawObjectEventArgs.Info parameter. To obtain the text for the filter conditions applied, use the View's ViewFilter.DisplayText property of the ColumnView.ActiveFilter object. Please refer to the Filter and Search topic for additional information on obtaining the current filter conditions.

The event's CustomDrawObjectEventArgs.Info parameter represents an instance of the DevExpress.XtraGrid.Drawing.GridFilterPanelInfoArgs type. This provides a number of properties which contain information on the inner elements of the filter panel. Some of these properties are described below:

Property

Description

Info.ActiveButtonInfo

Contains information (bounds and check state) on the Enable Filter check box.

Info.CloseButtonInfo

Contains information on the filter panel Close Button.

The Button property of the EditorButton class can be used to change the appearance of the Close button. For instance, to display a custom image within the button, set the Button.Kind property to ButtonPredefines.Glyph and assign an image to display to the Button.Image property.

The Appearance object allows you to change the Close button's appearance settings. Note that these settings are in effect only if the View is not painted using a WindowsXP theme or Office2003 scheme.

Info.DisplayText

Can be used to get and set the text displayed within the filter panel. Initially this property matches the value of the ViewFilter.DisplayText property of the ColumnView.ActiveFilter object.

Info.FilterActive

Specifies whether the filtering functionality is enabled. Manually changing this property will affect how the Activate Filter check box is painted (checked or unchecked).

Info.MRUButtonInfo

Contains information on the filter panel's button which opens the list containing the most recently used filter criteria. This button can be customized in the same manner as the Close button.

 

If the panel has been custom painted, set the CustomDrawEventArgs.Handled parameter to true to prevent the default painting.

IMPORTANT

Do not change cell values, modify the control's layout, or change the control's object model in the events used for custom control painting. Actions that update the layout can cause the control to malfunction.

Examples

The following code demonstrates how to manually repaint the filter panel.

using DevExpress.XtraGrid.Drawing;

private void Form3_Load1(object sender, EventArgs e) {
    CustomDrawFilterPanel(gridControl1, gridView1);
}

public static void CustomDrawFilterPanel(GridControl gridControl, GridView gridView) {
    gridView.ActiveFilterString = string.Format("[{0}] > 2", "ID");

    // Handle this event to paint the filter panel manually
    gridView.CustomDrawFilterPanel += (s, e) => {
        GridView view = s as GridView;
        GridFilterPanelInfoArgs info = e.Info as DevExpress.XtraGrid.Drawing.GridFilterPanelInfoArgs;
        e.Cache.FillRectangle(Color.BlanchedAlmond, e.Bounds);
        e.Appearance.ForeColor = Color.DimGray;
        e.Appearance.DrawString(e.Cache, info.DisplayText, info.TextBounds);
        SkinGridFilterPanelPainter painter = e.Painter as SkinGridFilterPanelPainter;
        info.ActiveButtonInfo.CheckState = view.ActiveFilterEnabled ? CheckState.Checked : CheckState.Unchecked;
        ObjectPainter.DrawObject(e.Cache, painter.CheckPainter, info.ActiveButtonInfo);
        ObjectPainter.DrawObject(e.Cache, painter.ButtonPainter, info.CustomizeButtonInfo);
        ObjectPainter.DrawObject(e.Cache, painter.ButtonPainter, info.CloseButtonInfo);
        e.Handled = true;
    };
}
See Also