DataGridView.CurrentCellAddress Propiedad

Definición

Obtiene los índices de fila y columna de la celda activa actualmente.

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

Valor de propiedad

Objeto Point que representa los índices de fila y columna de la celda activa actualmente.

Atributos

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar la CurrentCellAddress propiedad en un escenario de dibujo de fila. En el ejemplo, esta propiedad se usa para almacenar el índice de fila de la celda actual. Cuando el usuario cambia la celda actual a otra fila, la fila se fuerza a volver a pintarse.

Este código forma parte de un ejemplo más grande disponible en How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control.

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

Comentarios

Utilice esta propiedad para determinar la fila y la columna de la celda actual sin tener acceso a la celda directamente. Esto es útil para evitar el uso compartido de filas compartidas. Para obtener más información sobre cómo compartir filas, consulte Procedimientos recomendados para ajustar la escala del control DataGridView en Windows Forms.

Se aplica a

Consulte también