DataGridView.CellStateChanged 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
儲存格狀態變更時發生,例如儲存格失去或獲得焦點時。
public:
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
事件類型
範例
下列程式碼範例說明此事件的用法。
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
備註
如需如何處理事件的詳細資訊,請參閱 處理和引發事件。