ToolStripDropDownItem.DropDownOpened 事件

定义

ToolStripDropDown 已经打开时发生。

public:
 event EventHandler ^ DropDownOpened;
public event EventHandler DropDownOpened;
public event EventHandler? DropDownOpened;
member this.DropDownOpened : EventHandler 
Public Custom Event DropDownOpened As EventHandler 

事件类型

示例

下面的代码示例演示如何处理 DropDownOpened 多个 ToolStripDropDownItem 控件的事件。 此代码示例是为 ToolStripDropDownItem 类提供的一个更大示例的一部分。

// This method handles the DropDownOpened event from a 
// ToolStripDropDownItem. It displays the value of the 
// item's Text property in the form's StatusStrip control.
void toolStripDropDownItem_DropDownOpened(object sender, EventArgs e)
{
    ToolStripDropDownItem item = sender as ToolStripDropDownItem;

    string msg = String.Format("Item opened: {0}", item.Text);
    this.toolStripStatusLabel1.Text = msg;
}
' This method handles the DropDownOpened event from a 
' ToolStripDropDownItem. It displays the value of the 
' item's Text property in the form's StatusStrip control.
 Private Sub toolStripDropDownItem_DropDownOpened(ByVal sender As Object, ByVal e As EventArgs)

     Dim item As ToolStripDropDownItem = CType(sender, ToolStripDropDownItem)

     Dim msg As String = String.Format("Item opened: {0}", item.Text)
     Me.toolStripStatusLabel1.Text = msg

 End Sub

注解

当用户单击下拉项或调用 方法时, ShowDropDown 会发生此事件。 可以使用此事件动态填充 ToolStripDropDown

有关处理事件的详细信息,请参阅 处理和引发事件

适用于