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

セルの親行のインデックス。

次のコード例は、このメソッドの使用方法を示しています。 この例は、「方法: 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

注釈

このメソッドは、 DataGridView.OnCellMouseEnter メソッドに似ています。 これは、 DataGridView.CellMouseEnter イベントが発生したのと同じ状況で呼び出されますが、実際にはイベントは発生しません。

適用対象

こちらもご覧ください