共用方式為


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 Forms儲存格和資料行中較大型範例的一部分。

// 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 呼叫,但實際上不會引發事件。

適用於

另請參閱