示例#1
0
        // The dropdown has closed
        void ClosedDropdown(object sender, ToolStripDropDownClosedEventArgs args)
        {
            // The drop-down closed for some reason other than the item was clicked.
            switch (args.CloseReason)
            {
            case ToolStripDropDownCloseReason.AppClicked:
            case ToolStripDropDownCloseReason.AppFocusChange:
                // Clicked outside of the drop-down.
                // If the user has changed the text box, commit that change, else cancel
                if (textbox != null && textboxChanged)
                {
                    textbox.PerformClick();
                }
                else
                {
                    if (Canceled != null)
                    {
                        Canceled(this, EventArgs.Empty);
                    }
                }
                break;

            case ToolStripDropDownCloseReason.CloseCalled:
            case ToolStripDropDownCloseReason.Keyboard:
                // Canceled the drop down.
                if (Canceled != null)
                {
                    Canceled(this, EventArgs.Empty);
                }
                break;

            case ToolStripDropDownCloseReason.ItemClicked:
                // Do nothing here, the item clicked handler will handle it.
                break;
            }
        }