DataGridView.CellStateChanged イベント


セルが、フォーカスを取得したり失ったりなど、状態が変更したときに発生します。Occurs when a cell state changes, such as when the cell loses or gains focus.

 event System::Windows::Forms::DataGridViewCellStateChangedEventHandler ^ CellStateChanged;
public event System.Windows.Forms.DataGridViewCellStateChangedEventHandler CellStateChanged;
member this.CellStateChanged : System.Windows.Forms.DataGridViewCellStateChangedEventHandler 
Public Custom Event CellStateChanged As DataGridViewCellStateChangedEventHandler 

次のコード例は、このイベントの使用方法を示しています。The following code example illustrates the use of this event.

private void dataGridView1_CellStateChanged(object sender,
    DataGridViewCellStateChangedEventArgs e)
    DataGridViewElementStates state = e.StateChanged;
    string msg = String.Format("Row {0}, Column {1}, {2}",
        e.Cell.RowIndex, e.Cell.ColumnIndex, e.StateChanged);
    MessageBox.Show(msg, "Cell State Changed");
Private Sub dataGridView1_CellStateChanged(ByVal sender As Object, _
    ByVal e As DataGridViewCellStateChangedEventArgs) _
    Handles dataGridView1.CellStateChanged

    Dim state As DataGridViewElementStates = e.StateChanged
    Dim msg As String = String.Format( _
        "Row {0}, Column {1}, {2}", _
        e.Cell.RowIndex, e.Cell.ColumnIndex, e.StateChanged)
    MessageBox.Show(msg, "Cell State Changed")

End Sub


イベントを処理する方法の詳細については、次を参照してください。処理とイベントの発生します。For more information about how to handle events, see Handling and Raising Events.