ToolStripItemEventArgs.Item Właściwość

Definicja

Pobiera element ToolStripItem , dla którego mają być obsługiwane zdarzenia.

public:
 property System::Windows::Forms::ToolStripItem ^ Item { System::Windows::Forms::ToolStripItem ^ get(); };
public System.Windows.Forms.ToolStripItem Item { get; }
public System.Windows.Forms.ToolStripItem? Item { get; }
member this.Item : System.Windows.Forms.ToolStripItem
Public ReadOnly Property Item As ToolStripItem

Wartość właściwości

Element ToolStripItem , dla którego mają być obsługiwane zdarzenia.

Przykłady

W poniższym przykładzie kodu pokazano użycie tego elementu członkowskiego. W tym przykładzie program obsługi zdarzeń zgłasza wystąpienie ToolStrip.ItemAdded zdarzenia. Ten raport pomaga dowiedzieć się, kiedy wystąpi zdarzenie, i może pomóc w debugowaniu. Aby zgłosić wiele zdarzeń lub często występujących zdarzeń, rozważ zastąpienie MessageBox.Show komunikatu ciągiem Console.WriteLine lub dołączenie go do wielowierszowego TextBoxelementu .

Aby uruchomić przykładowy kod, wklej go w projekcie zawierającym wystąpienie typu ToolStrip o nazwie ToolStrip1. Następnie upewnij się, że program obsługi zdarzeń jest skojarzony ze zdarzeniem ToolStrip.ItemAdded .

private void ToolStrip1_ItemAdded(Object sender, ToolStripItemEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Item", e.Item );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "ItemAdded Event" );
}
Private Sub ToolStrip1_ItemAdded(sender as Object, e as ToolStripItemEventArgs) _ 
     Handles ToolStrip1.ItemAdded

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

End Sub

Dotyczy