DataGridView.CurrentCellAddress Vlastnost

Definice

Získá indexy řádků a sloupců aktuálně aktivní buňky.

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

Hodnota vlastnosti

A Point , který představuje indexy řádků a sloupců aktuálně aktivní buňky.

Atributy

Příklady

Následující příklad kódu ukazuje, jak použít CurrentCellAddress vlastnost ve scénáři malování řádků. V příkladu se tato vlastnost používá k uložení indexu řádku aktuální buňky. Když uživatel změní aktuální buňku na jiný řádek, je řádek nucen překreslovat sám.

Tento kód je součástí většího příkladu, který je k dispozici v tématu Postupy: Přizpůsobení vzhledu řádků v ovládacím prvku model 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

Poznámky

Tato vlastnost slouží k určení řádku a sloupce aktuální buňky bez přímého přístupu k buňce. To je užitečné, pokud chcete zabránit zrušení sdílení sdílených řádků. Další informace o sdílení řádků najdete v tématu Osvědčené postupy pro škálování ovládacího prvku model Windows Forms DataGridView.

Platí pro

Viz také