GrapeCity.Win.MultiRow.v80 アセンブリ > GrapeCity.Win.MultiRow 名前空間 > DropDownCustomFilterItem クラス : Check メソッド |
既定の実装では、Object.Equalsメソッドが呼び出されます。このメソッドをオーバーライドして新しい規則を定義できます。たとえば、値が10から20の間にある場合にそのセルを表示できるという規則を定義できます。
注意: |
---|
このメソッドをオーバーライドして新しいフィルタ規則を定義した場合は、Equalsメソッドも同時にオーバーライドして、同じフィルタ規則を持つ項目が等しいと見なされるようにする必要があります。 |
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); } }
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