ToolStripDropDownClosingEventArgs 类

定义

提供事件的数据 Closing

public ref class ToolStripDropDownClosingEventArgs : System::ComponentModel::CancelEventArgs
public class ToolStripDropDownClosingEventArgs : System.ComponentModel.CancelEventArgs
type ToolStripDropDownClosingEventArgs = class
    inherit CancelEventArgs
Public Class ToolStripDropDownClosingEventArgs
Inherits CancelEventArgs
继承
ToolStripDropDownClosingEventArgs

示例

下面的代码示例演示了此类型的用法。 在此示例中,事件处理程序报告事件的发生情况 Closing 。 此报告可帮助你了解事件发生的时间,并可以帮助你进行调试。 若要报告多个事件或频繁发生的事件,请考虑替换ShowConsole.WriteLine或将消息追加到多行TextBox

若要运行示例代码,请将其粘贴到包含命名ToolStripDropDown类型的ToolStripDropDown1实例的项目中。 然后,确保事件处理程序与 Closing 事件相关联。

private void ToolStripDropDown1_Closing(Object sender, ToolStripDropDownClosingEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "CloseReason", e.CloseReason );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Cancel", e.Cancel );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "Closing Event" );
}
Private Sub ToolStripDropDown1_Closing(sender as Object, e as ToolStripDropDownClosingEventArgs) _ 
     Handles ToolStripDropDown1.Closing

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "CloseReason", e.CloseReason)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Cancel", e.Cancel)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"Closing Event")

End Sub

注解

使用类中的数据 ToolStripDropDownClosingEventArgs 来确定当用户关闭下拉列表但在关闭列表之前要执行的操作。

构造函数

名称 说明
ToolStripDropDownClosingEventArgs(ToolStripDropDownCloseReason)

使用指定的关闭原因初始化类的新实例 ToolStripDropDownClosingEventArgs

属性

名称 说明
Cancel

获取或设置一个值,该值指示是否应取消事件。

(继承自 CancelEventArgs)
CloseReason

获取关闭的原因 ToolStripDropDown

方法

名称 说明
Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

适用于

另请参阅