DataGridView.InvalidateCell メソッド

定義

DataGridView のセルを無効化して、強制的に再描画します。

オーバーロード

InvalidateCell(DataGridViewCell)

DataGridView の指定されたセルを無効化して、強制的に再描画します。

InvalidateCell(Int32, Int32)

指定された行インデックスと列インデックスを含むセルを無効化して、強制的に再描画します。

InvalidateCell(DataGridViewCell)

DataGridView の指定されたセルを無効化して、強制的に再描画します。

public:
 void InvalidateCell(System::Windows::Forms::DataGridViewCell ^ dataGridViewCell);
public void InvalidateCell (System.Windows.Forms.DataGridViewCell dataGridViewCell);
member this.InvalidateCell : System.Windows.Forms.DataGridViewCell -> unit
Public Sub InvalidateCell (dataGridViewCell As DataGridViewCell)

パラメーター

dataGridViewCell
DataGridViewCell

無効化する DataGridViewCell

例外

dataGridViewCellDataGridView に属していません。

dataGridViewCellnullです。

次のコード例は、マウス ポインターが置かれているときにカスタム境界線で描画されるカスタマイズ DataGridViewCell されたメソッドでこのメソッドを使用する方法を示しています。 この例では、マウス ポインターが入ったり離れたりすると、セルは無効になります。

このコードは、「方法: 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

注釈

このメソッドは、通常はセルを再描画しない条件でセルを強制的に再描画する場合に便利です。 たとえば、外部イベントの結果として外観を変更するカスタム セル型でこのメソッドを使用できます。

塗りつぶしと無効化の詳細については、次を参照してください Invalidate

こちらもご覧ください

適用対象

InvalidateCell(Int32, Int32)

指定された行インデックスと列インデックスを含むセルを無効化して、強制的に再描画します。

public:
 void InvalidateCell(int columnIndex, int rowIndex);
public void InvalidateCell (int columnIndex, int rowIndex);
member this.InvalidateCell : int * int -> unit
Public Sub InvalidateCell (columnIndex As Integer, rowIndex As Integer)

パラメーター

columnIndex
Int32

無効化するセルの列インデックス。

rowIndex
Int32

無効化するセルの行インデックス。

例外

columnIndex が -1 未満か、コントロールの列数 -1 を上回っています。

  • または - rowIndex が、-1 未満か、コントロール内の行数から 1 を引いた値を超えています。

次のコード例は、ユーザーがマウス ポインターを置いたときにセルの外観を変更するカスタム セル型でこのメソッドを使用する方法を示しています。 この例は、「方法: 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

注釈

このメソッドは、通常はセルを再描画しない条件でセルを強制的に再描画する場合に便利です。 たとえば、外部イベントの結果として外観を変更するカスタム セル型でこのメソッドを使用できます。

塗りつぶしと無効化の詳細については、次を参照してください Invalidate

こちらもご覧ください

適用対象