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.v24.1.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
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.
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;
}
}