ToolStrip.ItemRemoved Zdarzenie

Definicja

Występuje, gdy element ToolStripItem jest usuwany z obiektu ToolStripItemCollection.

public:
 event System::Windows::Forms::ToolStripItemEventHandler ^ ItemRemoved;
public event System.Windows.Forms.ToolStripItemEventHandler ItemRemoved;
public event System.Windows.Forms.ToolStripItemEventHandler? ItemRemoved;
member this.ItemRemoved : System.Windows.Forms.ToolStripItemEventHandler 
Public Custom Event ItemRemoved As ToolStripItemEventHandler 

Typ 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 ItemRemoved 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 ItemRemoved .

private void ToolStrip1_ItemRemoved(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(), "ItemRemoved Event" );
}
Private Sub ToolStrip1_ItemRemoved(sender as Object, e as ToolStripItemEventArgs) _ 
     Handles ToolStrip1.ItemRemoved

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

End Sub

Uwagi

Aby uzyskać więcej informacji na temat obsługi zdarzeń, zobacz Obsługa i podnoszenie zdarzeń.

Dotyczy