ToolStripItem.OnMouseLeave(EventArgs) Método
Definição
Aciona o evento MouseLeave.Raises the MouseLeave event.
protected:
virtual void OnMouseLeave(EventArgs ^ e);
protected virtual void OnMouseLeave (EventArgs e);
abstract member OnMouseLeave : EventArgs -> unit
override this.OnMouseLeave : EventArgs -> unit
Protected Overridable Sub OnMouseLeave (e As EventArgs)
Parâmetros
Exemplos
O exemplo de código a seguir demonstra como substituir OnMouseLeave o método.The following code example demonstrates how to override the OnMouseLeave method. Este exemplo de código faz parte de um exemplo maior fornecido para ToolStripItem a classe.This code example is part of a larger example provided for the ToolStripItem class.
// This method defines the behavior of the MouseLeave event.
// It sets the state of the rolloverValue field to false and
// tells the control to repaint.
protected override void OnMouseLeave(EventArgs e)
{
base.OnMouseLeave(e);
this.rolloverValue = false;
this.Invalidate();
}
' This method defines the behavior of the MouseLeave event.
' It sets the state of the rolloverValue field to false and
' tells the control to repaint.
Protected Overrides Sub OnMouseLeave(e As EventArgs)
MyBase.OnMouseLeave(e)
Me.rolloverValue = False
Me.Invalidate()
End Sub
Comentários
A geração de um evento invoca o manipulador de eventos por meio de um delegado.Raising an event invokes the event handler through a delegate. Para obter mais informações, consulte manipulando e gerando eventos.For more information, see Handling and Raising Events.
O OnMouseLeave método também permite que classes derivadas manipulem o evento sem anexar um delegado.The OnMouseLeave method also allows derived classes to handle the event without attaching a delegate. Essa é a técnica preferida para manipular o evento em uma classe derivada.This is the preferred technique for handling the event in a derived class.
Notas aos Herdeiros
Ao substituir OnMouseLeave(EventArgs) em uma classe derivada, certifique-se de chamar o método da OnMouseLeave(EventArgs) classe base para que os delegados registrados recebam o evento.When overriding OnMouseLeave(EventArgs) in a derived class, be sure to call the base class's OnMouseLeave(EventArgs) method so that registered delegates receive the event.