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 窗体 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) 委托接收事件。

适用于

另请参阅