GrapeCity.Win.MultiRow.v80 アセンブリ > GrapeCity.Win.MultiRow 名前空間 : DropDownCustomFilterItem クラス |
Public Class DropDownCustomFilterItem Inherits DropDownItem Implements INamedObject
public class DropDownCustomFilterItem : DropDownItem, INamedObject
フィルタ操作は、HeaderDropDownList.CellIndexまたはHeaderDropDownList.CellNameによって指定された、HeaderDropDownList.StartRowとHeaderDropDownList.EndRowの間にあるセルに適用されます。
DropDownCustomFilterItemを使用すると、フィルタ規則を手動で定義できます。特別なFilterValueによってDropDownCustomFilterItemを作成してから、その項目をHeaderDropDownListに追加します。項目をクリックすると、そのFormattedValueがフィルタ値と一致するセルが表示され、それ以外のセルは非表示になります。
DropDownAutoFilterItemは、既定のテキストを持つDropDownCustomFilterItemオブジェクトを自動生成できます。生成された項目のテキスト、イメージ、またはその他のプロパティを変更する場合は、DropDownItemNeededイベントを使用して項目を独自に作成します。また、DropDownAutoFilterItemの代わりに、DropDownCustomFilterItemオブジェクトをHeaderDropDownListに直接追加することもできます。
既定のフィルタ規則では、FilterValueに対してSystem.Object.Equals(System.Object,System.Object)メソッドを実行した結果trueが返されるオブジェクトが等しいと見なされます。CheckメソッドまたはEqualsメソッドをオーバーライドすることで、新しい規則を定義できます。
void setFourthColumnDropDownListButton_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 show all item. dropDownItemCollection.Add(new DropDownShowAllFilterItem()); // custom range item. dropDownItemCollection.Add(new PopupFilterItem()); // Get second column header cell. ColumnHeaderCell columnHeaderCell = this.gcMultiRow1.ColumnHeaders[0][3] as ColumnHeaderCell; columnHeaderCell.DropDownList = headerDropDownList; } public class PopupFilterItem : DropDownCustomFilterItem { public override string Text { get { if (this.Checked) { return min.ToString() + " to " + max.ToString(); } return "(Custom)"; } set { } } int max = -1; int min = -1; protected override bool Check(object value) { // check the value whether in specific range. int checkedValue = int.Parse(value.ToString()); return (checkedValue >= min && checkedValue <= max); } protected override void OnClick(EventArgs e) { // Initialize pop up form. Form form = new Form(); FlowLayoutPanel panel = new FlowLayoutPanel(); panel.Height = form.Height; Label label1 = new Label(); label1.Text = "Min Value:"; Label label2 = new Label(); label2.Text = "MaxValue:"; NumericUpDown numericUpDown1 = new NumericUpDown(); NumericUpDown numericUpDown2 = new NumericUpDown(); numericUpDown2.Maximum = 1000; numericUpDown2.Value = 50; Button okButton = new Button(); okButton.Text = "OK"; okButton.DialogResult = DialogResult.OK; form.AcceptButton = okButton; form.Controls.Add(panel); panel.Controls.Add(label1); panel.Controls.Add(numericUpDown1); panel.Controls.Add(label2); panel.Controls.Add(numericUpDown2); panel.Controls.Add(okButton); DialogResult result = form.ShowDialog(); // If input a range and click OK button. Update range. if (result == DialogResult.OK) { min = (int)(numericUpDown1.Value); max = (int)(numericUpDown2.Value); } else { min = int.MinValue; max = int.MaxValue; } base.OnClick(e); } }
Private Sub setFourthColumnDropDownListButton_Click(ByVal sender As Object, ByVal e As EventArgs) Handles setFourthColumnDropDownListButton.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 show all item. dropDownItemCollection.Add(New DropDownShowAllFilterItem()) ' custom range item. dropDownItemCollection.Add(New PopupFilterItem()) ' Get second column header cell. Dim columnHeaderCell As ColumnHeaderCell = TryCast(Me.gcMultiRow1.ColumnHeaders(0)(3), ColumnHeaderCell) columnHeaderCell.DropDownList = headerDropDownList End Sub Public Class PopupFilterItem Inherits DropDownCustomFilterItem Public Overloads Overrides Property Text() As String Get If Me.Checked Then Return min.ToString() + " to " + max.ToString() End If Return "(Custom)" End Get Set(ByVal value As String) End Set End Property Private max As Integer = -1 Private min As Integer = -1 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 >= min AndAlso checkedValue <= max) End Function Protected Overloads Overrides Sub OnClick(ByVal e As EventArgs) ' Initialize pop up form. Dim form As New Form() Dim panel As New FlowLayoutPanel() panel.Height = form.Height Dim label1 As New Label() label1.Text = "Min Value:" Dim label2 As New Label() label2.Text = "MaxValue:" Dim numericUpDown1 As New NumericUpDown() Dim numericUpDown2 As New NumericUpDown() numericUpDown2.Maximum = 1000 numericUpDown2.Value = 50 Dim okButton As New Button() okButton.Text = "OK" okButton.DialogResult = DialogResult.OK form.AcceptButton = okButton form.Controls.Add(panel) panel.Controls.Add(label1) panel.Controls.Add(numericUpDown1) panel.Controls.Add(label2) panel.Controls.Add(numericUpDown2) panel.Controls.Add(okButton) Dim result As DialogResult = form.ShowDialog() ' If input a range and click OK button. Update range. If result = DialogResult.OK Then min = CInt(numericUpDown1.Value) max = CInt(numericUpDown2.Value) Else min = Integer.MinValue max = Integer.MaxValue End If MyBase.OnClick(e) End Sub End Class
System.Object
GrapeCity.Win.MultiRow.DropDownItem
GrapeCity.Win.MultiRow.DropDownCustomFilterItem