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
注解
有关如何处理事件的详细信息,请参阅 处理和引发事件。