GrapeCity.Win.MultiRow Namespace > DropDownAutoFilterItem Class : DropDownItemNeeded Event |
Public Event DropDownItemNeeded As EventHandler(Of DropDownItemNeededEventArgs)
Dim instance As DropDownAutoFilterItem Dim handler As EventHandler(Of DropDownItemNeededEventArgs) AddHandler instance.DropDownItemNeeded, handler
public event EventHandler<DropDownItemNeededEventArgs> DropDownItemNeeded
The event handler receives an argument of type DropDownItemNeededEventArgs containing data related to this event. The following DropDownItemNeededEventArgs properties provide information specific to this event.
Property | Description |
---|---|
DropDownCustomFilterItem | Gets or sets the custom DropDownCustomFilterItem. |
FilterValue | Gets the filter value. |
Handled | (Inherited from System.ComponentModel.HandledEventArgs) |
void setThirdColumnDropDownListButton_Click(object sender, EventArgs e) { // Create a header drop down list without default down down items. HeaderDropDownList headerDropDownList = new HeaderDropDownList(); DropDownItemCollection dropDownItemCollection = headerDropDownList.Items; // Initialize drop down items manually. // Add to show all items. dropDownItemCollection.Add(new DropDownShowAllFilterItem()); DropDownAutoFilterItem autoFilterItem = new DropDownAutoFilterItem(); autoFilterItem.DropDownItemNeeded += new EventHandler<DropDownItemNeededEventArgs>(autoFilterItem_DropDownItemNeeded); // custom range item. dropDownItemCollection.Add(autoFilterItem); // Get second column header cell. ColumnHeaderCell columnHeaderCell = this.gcMultiRow1.ColumnHeaders[0][2] as ColumnHeaderCell; columnHeaderCell.DropDownList = headerDropDownList; } void autoFilterItem_DropDownItemNeeded(object sender, DropDownItemNeededEventArgs e) { int filterValue = int.Parse(e.FilterValue.ToString()); e.DropDownCustomFilterItem = new AutoRangeFilterItem(filterValue / 100); e.Handled = true; } public class AutoRangeFilterItem : DropDownCustomFilterItem { public AutoRangeFilterItem(int filterValue) : base(filterValue) { } public override string Text { get { return ((int)FilterValue * 100).ToString() + " to " + (((int)FilterValue + 1) * 100).ToString(); } set { } } protected override bool Check(object value) { // check whether the value is in specific range. int checkedValue = int.Parse(value.ToString()); return (checkedValue >= ((int)FilterValue * 100) && checkedValue <= (((int)FilterValue + 1) * 100)); } }
Private Sub setThirdColumnDropDownListButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setThirdColumnDropDownListButton.Click ' Create a header drop down list without default down down items. Dim headerDropDownList As New HeaderDropDownList() Dim dropDownItemCollection As DropDownItemCollection = headerDropDownList.Items ' Initialize drop down items manually. ' Add to show all items. dropDownItemCollection.Add(New DropDownShowAllFilterItem()) Dim autoFilterItem As New DropDownAutoFilterItem() AddHandler autoFilterItem.DropDownItemNeeded, AddressOf autoFilterItem_DropDownItemNeeded ' custom range item. dropDownItemCollection.Add(autoFilterItem) ' Get second column header cell. Dim columnHeaderCell As ColumnHeaderCell = TryCast(Me.gcMultiRow1.ColumnHeaders(0)(2), ColumnHeaderCell) columnHeaderCell.DropDownList = headerDropDownList End Sub Private Sub autoFilterItem_DropDownItemNeeded(ByVal sender As Object, ByVal e As DropDownItemNeededEventArgs) Dim filterValue As Integer = Integer.Parse(e.FilterValue.ToString()) e.DropDownCustomFilterItem = New AutoRangeFilterItem(filterValue / 100) e.Handled = True End Sub Public Class AutoRangeFilterItem Inherits DropDownCustomFilterItem Public Sub New(ByVal filterValue As Integer) MyBase.New(filterValue) End Sub Public Overloads Overrides Property Text() As String Get Return (DirectCast(FilterValue, Integer) * 100).ToString() + " to " + ((DirectCast(FilterValue, Integer) + 1) * 100).ToString() End Get Set(ByVal value As String) End Set End Property Protected Overloads Overrides Function Check(ByVal value As Object) As Boolean ' check the value whether in specific range. Dim checkedValue As Integer = Integer.Parse(value.ToString()) Return (checkedValue >= (DirectCast(FilterValue, Integer) * 100) AndAlso checkedValue <= ((DirectCast(FilterValue, Integer) + 1) * 100)) End Function End Class
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2