DataGridView.OnMouseLeave(EventArgs) Metoda

Definicja

MouseLeave Zgłasza zdarzenie.

protected:
 override void OnMouseLeave(EventArgs ^ e);
protected override void OnMouseLeave (EventArgs e);
override this.OnMouseLeave : EventArgs -> unit
Protected Overrides Sub OnMouseLeave (e As EventArgs)

Parametry

e
EventArgs

Element EventArgs zawierający dane zdarzenia.

Przykłady

Poniższy przykład kodu ilustruje użycie tej metody. Ten przykład jest częścią większego przykładu dostępnego w temacie How to: Customize Cells and Columns in the Windows Forms DataGridView Control (Dostosowywanie komórek i kolumn w kontrolce DataGridView) przez rozszerzenie ich zachowania i wyglądu.

// Force the cell to repaint itself when the mouse pointer enters it.
protected override void OnMouseEnter(int rowIndex)
{
    this.DataGridView.InvalidateCell(this);
}

// Force the cell to repaint itself when the mouse pointer leaves it.
protected override void OnMouseLeave(int rowIndex)
{
    this.DataGridView.InvalidateCell(this);
}
' Force the cell to repaint itself when the mouse pointer enters it.
Protected Overrides Sub OnMouseEnter(ByVal rowIndex As Integer)
    Me.DataGridView.InvalidateCell(Me)
End Sub

' Force the cell to repaint itself when the mouse pointer leaves it.
Protected Overrides Sub OnMouseLeave(ByVal rowIndex As Integer)
    Me.DataGridView.InvalidateCell(Me)
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 OnMouseLeave 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 OnMouseLeave(EventArgs) w klasie pochodnej należy wywołać metodę klasy OnMouseLeave(EventArgs) bazowej, aby zarejestrowani delegaci odbierali zdarzenie.

Dotyczy

Zobacz też