DataGridView.CurrentCellChanged Evento
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Ocorre quando a CurrentCell propriedade muda.
public:
event EventHandler ^ CurrentCellChanged;
public event EventHandler CurrentCellChanged;
member this.CurrentCellChanged : EventHandler
Public Custom Event CurrentCellChanged As EventHandler
Tipo de Evento
Exemplos
O seguinte exemplo de código ilustra a utilização deste evento. Este exemplo faz parte de um exemplo maior disponível em Como: Personalizar a Aparência das Linhas no Controlo 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
Observações
Para mais informações sobre como gerir eventos, consulte Gestão e Levantamento de Eventos.