DataGridViewCell.OnMouseLeave(Int32) 方法

定义

在鼠标指针离开单元格时调用。

protected:
 virtual void OnMouseLeave(int rowIndex);
protected virtual void OnMouseLeave (int rowIndex);
abstract member OnMouseLeave : int -> unit
override this.OnMouseLeave : int -> unit
Protected Overridable Sub OnMouseLeave (rowIndex As Integer)

参数

rowIndex
Int32

该单元格的父行索引。

示例

下面的代码示例演示了此方法的用法。 此示例是如何:通过扩展其行为和外观自定义 DataGridView 控件中Windows 窗体单元格和列中提供的更大示例的一部分。

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

注解

此方法类似于 DataGridView.OnCellMouseLeave 方法。 它在引发事件的相同情况下 DataGridView.CellMouseLeave 调用,但它实际上不会引发事件。

适用于

另请参阅