DataGridView.InvalidateRow(Int32) 메서드

정의

DataGridView의 지정된 행을 무효화하여 행이 다시 그려지도록 합니다.

public:
 void InvalidateRow(int rowIndex);
public void InvalidateRow (int rowIndex);
member this.InvalidateRow : int -> unit
Public Sub InvalidateRow (rowIndex As Integer)

매개 변수

rowIndex
Int32

무효화할 행의 인덱스입니다.

예외

rowIndex가 0부터 행 수까지의 값에서 1을 뺀 값 범위에 있지 않습니다.

예제

다음 코드 예제에서는 행 그리기 시나리오에서 메서드를 사용 InvalidateRow 하는 방법을 보여 줍니다. 이 예제에서는 현재 셀이 변경될 때 행이 무효화되어 행이 다시 그려지도록 합니다.

이 코드는 방법: Windows Forms DataGridView 컨트롤에서 행 모양 사용자 지정에서 사용할 수 있는 더 큰 예제의 일부입니다.

// Forces the row to repaint itself when the user changes the 
// current cell. This is necessary to refresh the focus rectangle.
void dataGridView1_CurrentCellChanged(object sender, EventArgs e)
{
    if (oldRowIndex != -1)
    {
        this.dataGridView1.InvalidateRow(oldRowIndex);
    }
    oldRowIndex = this.dataGridView1.CurrentCellAddress.Y;
}
' Forces the row to repaint itself when the user changes the 
' current cell. This is necessary to refresh the focus rectangle.
Sub dataGridView1_CurrentCellChanged(ByVal sender As Object, _
    ByVal e As EventArgs) Handles dataGridView1.CurrentCellChanged

    If oldRowIndex <> -1 Then
        Me.dataGridView1.InvalidateRow(oldRowIndex)
    End If
    oldRowIndex = Me.dataGridView1.CurrentCellAddress.Y

End Sub

설명

이 메서드를 사용하여 행을 강제로 다시 칠합니다. 이 메서드는 또는 RowPostPaint 이벤트를 처리하는 소유자 그리기 시나리오에서 RowPrePaint 유용합니다.

그리기 및 무효화에 대한 자세한 내용은 를 참조하세요 Invalidate.

적용 대상

추가 정보