語言

DataGridView.OnMouseLeave(EventArgs) 方法

定義

引發 MouseLeave 事件。

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

參數

e
EventArgs

一個 EventArgs 包含事件資料的 。

範例

以下程式碼範例說明此方法的使用。 此範例是如何:透過擴展Windows Forms DataGridView 控制項的行為與外觀來自訂儲存格與欄位 中較大範例的一部分。

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

備註

發起事件會透過代理呼叫事件處理者。 欲了解更多資訊,請參閱 處理與提升事件。

此 OnMouseLeave 方法也允許衍生類別在不附加代理的情況下處理事件。 這是在衍生類別中處理事件的首選技術。

給繼承者的注意事項

在導出類別中覆寫 OnMouseLeave(EventArgs) 時,務必呼叫基底類別的方法 OnMouseLeave(EventArgs) ,讓註冊代理接收事件。

適用於

另請參閱