DataGridView.CurrentCellAddress 속성

정의

현재 활성화된 셀의 행 및 열 인덱스를 가져옵니다.

public:
 property System::Drawing::Point CurrentCellAddress { System::Drawing::Point get(); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.Point CurrentCellAddress { get; }
[<System.ComponentModel.Browsable(false)>]
member this.CurrentCellAddress : System.Drawing.Point
Public ReadOnly Property CurrentCellAddress As Point

속성 값

현재 활성화된 셀의 행 및 열 인덱스를 나타내는 Point입니다.

특성

예제

다음 코드 예제에서는 사용 CurrentCellAddress 하는 방법을 보여 줍니다는 행 그리기 시나리오에서 속성입니다. 예제에서 이 속성은 현재 셀의 행 인덱스 저장에 사용됩니다. 사용자가 현재 셀을 다른 행으로 변경하면 행 자체를 다시 칠해야 합니다.

이 코드는 방법: 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

설명

셀에 직접 액세스하지 않고 현재 셀의 행과 열을 확인하려면 이 속성을 사용합니다. 공유 행을 공유하지 않도록 하는 데 유용합니다. 행 공유에 대한 자세한 내용은 Windows Forms DataGridView 컨트롤의 크기를 조정하는 최선의 방법을 참조하세요.

적용 대상

추가 정보