DataGridView.CurrentCellChanged 事件

定義

當房產變更時 CurrentCell 發生。

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

事件類型

範例

以下程式碼範例說明了此事件的使用方式。 此範例是《 如何:自訂 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

備註

欲了解更多如何處理事件的資訊,請參閱 「處理與提升事件」。

適用於

另請參閱