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에 속하지 않는 경우

dataGridViewCell이(가) null인 경우

예제

다음 코드 예제에서는 마우스 포인터를 놓을 때 사용자 지정 테두리로 그린 사용자 지정 DataGridViewCell 된에서이 메서드를 사용 하는 방법을 보여 줍니다. 이 예제에서는 마우스 포인터가 들어오거나 나가면 셀이 무효화됩니다.

이 코드는 방법: 동작 및 모양을 확장하여 Windows Forms 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 Forms 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.

추가 정보

적용 대상