GrapeCity MultiRow Windows Forms Documentation
OnClick Method (DropDownCustomFilterItem)
Example 


The System.EventArgs instance that contains the event data.
Raises the DropDownItem.Click event.
Syntax
<TakeCellFreezeAttribute()>
Protected Overrides Sub OnClick( _
   ByVal e As EventArgs _
) 
Dim instance As DropDownCustomFilterItem
Dim e As EventArgs
 
instance.OnClick(e)
[TakeCellFreeze()]
protected override void OnClick( 
   EventArgs e
)

Parameters

e
The System.EventArgs instance that contains the event data.
Example
The following code example shows how to use this method to customize filter logic. This code example is part of a larger example provided for the DropDownList property.
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 whether the value is 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 whether the value is 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
Requirements

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

See Also

Reference

DropDownCustomFilterItem Class
DropDownCustomFilterItem Members

 

 


Copyright © GrapeCity, inc. All rights reserved.