windowsforms-devexpress-dot-xtratreelist-dot-treelist-bac9c2c4.md
Allows you to customize a column’s dropdown calendar before it is displayed.
Namespace : DevExpress.XtraTreeList
Assembly : DevExpress.XtraTreeList.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList
[DXCategory("Behavior")]
public event FilterPopupDateEventHandler ShowFilterPopupDate
<DXCategory("Behavior")>
Public Event ShowFilterPopupDate As FilterPopupDateEventHandler
The ShowFilterPopupDate event's data class is DevExpress.XtraTreeList.FilterPopupDateEventArgs.
If the OptionsColumnFilter.FilterPopupMode property is set to Date , the Column’s Filter DropDown is displayed as a calendar. In this mode, you can handle the ShowFilterPopupDate event to customize the dropdown (for instance, disable or hide particlar items). This event is raised each time before the filter dropdown is displayed.
The following example shows how to add a new item to the Hired Column’s Filter DropDown.
using System;
using System.Windows.Forms;
using DevExpress.XtraTreeList;
using DevExpress.Data.Filtering;
namespace ShowFilterPopupDate
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.table1TableAdapter.Fill(this._treelistdb__2_DataSet.Table1);
}
private void treeList1_ShowFilterPopupDate(object sender, FilterPopupDateEventArgs e)
{
if (e.Column.FieldName != "Hired") return;
DateTime firstDayOfFirstYear = new DateTime(1982, 1, 1);
DateTime lastDayOfFirstYear = new DateTime(1982, 12, 31);
CriteriaOperator firstDay = new BinaryOperator(
e.Column.FieldName, firstDayOfFirstYear, BinaryOperatorType.GreaterOrEqual);
CriteriaOperator lastDay = new BinaryOperator(
e.Column.FieldName, lastDayOfFirstYear, BinaryOperatorType.Less);
CriteriaOperator crit = new GroupOperator(GroupOperatorType.And, firstDay, lastDay);
e.List.Add(new DevExpress.XtraEditors.FilterDateElement("Year of Foundation", "", crit));
}
}
}
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraTreeList
Imports DevExpress.Data.Filtering
Namespace ShowFilterPopupDate
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Me.table1TableAdapter.Fill(Me._treelistdb__2_DataSet.Table1)
End Sub
Private Sub treeList1_ShowFilterPopupDate(ByVal sender As Object, ByVal e As FilterPopupDateEventArgs) Handles treeList1.ShowFilterPopupDate
If e.Column.FieldName <> "Hired" Then
Return
End If
Dim firstDayOfFirstYear As New DateTime(1982, 1, 1)
Dim lastDayOfFirstYear As New DateTime(1982, 12, 31)
Dim firstDay As CriteriaOperator = New BinaryOperator(e.Column.FieldName, firstDayOfFirstYear, BinaryOperatorType.GreaterOrEqual)
Dim lastDay As CriteriaOperator = New BinaryOperator(e.Column.FieldName, lastDayOfFirstYear, BinaryOperatorType.Less)
Dim crit As CriteriaOperator = New GroupOperator(GroupOperatorType.And, firstDay, lastDay)
e.List.Add(New DevExpress.XtraEditors.FilterDateElement("Year of Foundation", "", crit))
End Sub
End Class
End Namespace
See Also