DataGridViewCell.OnMouseEnter(Int32) 方法

定义

当鼠标指针移到单元格上时调用。

protected:
 virtual void OnMouseEnter(int rowIndex);
protected virtual void OnMouseEnter (int rowIndex);
abstract member OnMouseEnter : int -> unit
override this.OnMouseEnter : int -> unit
Protected Overridable Sub OnMouseEnter (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.OnCellMouseEnter 方法。 它在引发事件的相同情况下 DataGridView.CellMouseEnter 调用,但它实际上不会引发事件。

适用于

另请参阅