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 

事件類型

範例

下列程式碼範例示範如何處理多個 ToolStripDropDownItem 控制項的事件 DropDownOpened 。 此程式碼範例是針對 類別提供的較大範例的 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 入 。

如需處理事件的詳細資訊,請參閱 處理和引發事件

適用於