Skip to main content
A newer version of this page is available. .

ColumnView.FilterPopupExcelPrepareTemplate Event

Allows you to replace the UI for the Excel-styled menus’ “Values” tab. Also affects editors generated by the Filtering UI Context component attached to this Data Grid.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v19.1.dll

Declaration

[DXCategory("Appearance")]
public event FilterPopupExcelPrepareTemplateEventHandler FilterPopupExcelPrepareTemplate

Event Data

The FilterPopupExcelPrepareTemplate event's data class is DevExpress.XtraGrid.Views.Grid.FilterPopupExcelPrepareTemplateEventArgs.

Remarks

The FilterPopupExcelPrepareTemplate event allows you to change the items’ visual representation only. To modify the items themselves, handle the ColumnView.FilterPopupExcelData event instead.

In the example below, the FilterPopupExcelPrepareTemplate event replaces a default checked list box with a custom “TileList” control.

Data Grid - PrepareTemplate


using DevExpress.Utils.Filtering;
using DevExpress.Utils.Controls;

//replace the filtering UI template
private void GridView1_FilterPopupExcelPrepareTemplate(object sender, DevExpress.XtraGrid.Views.Grid.FilterPopupExcelPrepareTemplateEventArgs e) {
    if (e.PropertyPath == "CategoryID")
        e.Template = new TileList() { Images = categoryImages };
}

//a custom TileList control that replaces default check lists
public partial class TileList : XtraUserControl, IXtraResizableControl {
    public TileList() {
        InitializeComponent();
        Part_Values.CustomizeItem += PART_Values_CustomizeItem;
    }
    public SvgImageCollection Images {
        get;
        set;
    }
    public Size ImageSize {
        get { return new Size(Part_Values.ItemHeight - 8, Part_Values.ItemHeight - 8); }
        set { Part_Values.ItemHeight = Math.Max(40, value.Height + 8); }
    }
    protected override void OnParentChanged(System.EventArgs e) {
        base.OnParentChanged(e);
        if(Parent != null)
            Part_Values.BackColor = FindForm().BackColor;
    }
    void PART_Values_CustomizeItem(object sender, CustomizeTemplatedItemEventArgs e) {
        if(Images == null)
            return;
        var tileElement = e.TemplatedItem.Elements[0];
        if(e.Value is Enum) {
            tileElement.Image = Images.GetImage(e.Value.ToString().ToLowerInvariant(), ImageSize);
            return;
        }
        if(e.Value is int) {
            tileElement.Image = Images.GetImage((int)e.Value, ImageSize);
            return;
        }
        tileElement.Image = Images.GetImage("all", ImageSize);
    }
    Size IXtraResizableControl.MaxSize {
        get { return new Size(0, GetHeight()); }
    }
    Size IXtraResizableControl.MinSize {
        get { return new Size(0, GetHeight()); }
    }
    int GetHeight() {
        return (Part_Values.Items.Count > 0) ? Part_Values.CalcBestSize().Height : Part_Values.ItemHeight;
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FilterPopupExcelPrepareTemplate event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also