DataGridView.CurrentCellAddress Özellik

Tanım

Etkin olan hücrenin satır ve sütun dizinlerini alır.

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

Özellik Değeri

Point Etkin olan hücrenin satır ve sütun dizinlerini temsil eden bir.

Öznitelikler

Örnekler

Aşağıdaki kod örneği, bir satır boyama senaryosunda özelliğinin CurrentCellAddress nasıl kullanılacağını gösterir. Örnekte, bu özellik geçerli hücrenin satır dizinini depolamak için kullanılır. Kullanıcı geçerli hücreyi farklı bir satıra değiştirdiğinde, satır kendisini yeniden boyamaya zorlanır.

Bu kod, Nasıl yapılır: Windows Forms DataGridView Denetimindeki Satırların Görünümünü Özelleştirme bölümünde bulunan daha büyük bir örneğin parçasıdır.

// 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

Açıklamalar

Hücreye doğrudan erişmeden geçerli hücrenin satır ve sütununu belirlemek için bu özelliği kullanın. Bu, paylaşılan satırların paylaşılmamasını önlemek için yararlıdır. Satır paylaşımı hakkında daha fazla bilgi için bkz. Windows Forms DataGridView Denetimini Ölçeklendirmeye Yönelik En İyi Yöntemler.

Şunlara uygulanır

Ayrıca bkz.