DataGridView.CurrentCellChanged Evento

Definición

Se produce cuando cambia la CurrentCell propiedad.

public:
 event EventHandler ^ CurrentCellChanged;
public event EventHandler CurrentCellChanged;
public event EventHandler? CurrentCellChanged;
member this.CurrentCellChanged : EventHandler 
Public Custom Event CurrentCellChanged As EventHandler 

Tipo de evento

Ejemplos

En el ejemplo de código siguiente se muestra el uso de este evento. Este ejemplo 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

Para obtener más información sobre cómo controlar eventos, consulte Control y generación de eventos.

Se aplica a

Consulte también