ColumnView.CustomDrawFilterPanel Event
Enables you to paint the filter panel manually.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v24.2.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
#Declaration
[DXCategory("CustomDraw")]
public event CustomDrawObjectEventHandler CustomDrawFilterPanel
#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 Custom |
Bounds |
Returns a value specifying limits for the drawing area.
Inherited from Custom |
Cache |
Provides methods to paint on drawing surfaces in GDI+ and Direct |
Graphics |
A GDI+ drawing surface. Use the Custom |
Handled |
Gets or sets a value specifying whether an event was handled and that the default element painting is therefore not required.
Inherited from Custom |
Info | Gets an object containing information about the painted element. |
Painter | Gets the painter object that provides the default element painting mechanism. |
The event data class exposes the following methods:
Method | Description |
---|---|
Default |
Performs default painting of an element.
Inherited from Custom |
Draw |
Paints the required HTML template inside an element that raised this event. The context parameter allows you to assign an object that transfers mouse events to template elements.
Inherited from Custom |
Draw |
Paints the required HTML template inside an element that raised this event.
Inherited from Custom |
#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 FilterPanelText property. Refer to the Filter and Search topic for more information.
The event’s CustomDrawObjectEventArgs.Info is an instance of DevExpress.XtraGrid.Drawing.GridFilterPanelInfoArgs. Its properties contain information on the inner elements of the filter panel:
Property | Description |
---|---|
Info. | Contains information (bounds and check state) on the Enable Filter check box. |
Info. | Contains information on the filter panel Close Button. The Button property of the Editor 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 Windows |
Info. | Can be used to get and set the text displayed within the filter panel. Initially this property matches the value of the Filter |
Info. | 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. | 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.
#Example
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;
};
}