ToolStripItem.OnDoubleClick(EventArgs) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
引发 DoubleClick 事件。
protected:
virtual void OnDoubleClick(EventArgs ^ e);
protected virtual void OnDoubleClick(EventArgs e);
abstract member OnDoubleClick : EventArgs -> unit
override this.OnDoubleClick : EventArgs -> unit
Protected Overridable Sub OnDoubleClick (e As EventArgs)
参数
示例
下面的代码示例演示如何重写 OnDoubleClick 方法。 该代码示例是 ToolStripItem 类中的一个较大示例的一部分。
// The method defines the behavior of the DoubleClick
// event. It shows a MessageBox with the item's text.
protected override void OnDoubleClick(EventArgs e)
{
base.OnDoubleClick(e);
string msg = String.Format("Item: {0}", this.Text);
MessageBox.Show(msg);
}
' The method defines the behavior of the DoubleClick
' event. It shows a MessageBox with the item's text.
Protected Overrides Sub OnDoubleClick(e As EventArgs)
MyBase.OnDoubleClick(e)
Dim msg As String = String.Format("Item: {0}", Me.Text)
MessageBox.Show(msg)
End Sub
注解
引发事件会通过委托调用事件处理程序。 有关详细信息,请参阅 处理和引发事件。
该方法 OnDoubleClick 还允许派生类在不附加委托的情况下处理事件。 这是处理派生类中的事件的首选技术。
继承者说明
在派生类中重写 OnDoubleClick(EventArgs) 时,请务必调用基类的方法,以便已注册的 OnDoubleClick(EventArgs) 委托接收事件。