ToolStripItem.OnDoubleClick(EventArgs) Metoda

Definicja

DoubleClick Zgłasza zdarzenie.

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)

Parametry

e
EventArgs

Element EventArgs zawierający dane zdarzenia.

Przykłady

W poniższym przykładzie kodu pokazano, jak zastąpić metodę OnDoubleClick . Ten przykład kodu jest częścią większego przykładu podanego ToolStripItem dla klasy.

// 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

Uwagi

Podnoszenie zdarzenia wywołuje program obsługi zdarzeń przez delegata. Aby uzyskać więcej informacji, zobacz Obsługa i podnoszenie zdarzeń.

Metoda OnDoubleClick umożliwia również klasom pochodnym obsługę zdarzenia bez dołączania delegata. Jest to preferowana technika obsługi zdarzenia w klasie pochodnej.

Uwagi dotyczące dziedziczenia

Podczas zastępowania OnDoubleClick(EventArgs) w klasie pochodnej należy wywołać metodę klasy OnDoubleClick(EventArgs) bazowej, aby zarejestrowani delegaci otrzymywali zdarzenie.

Dotyczy