DataGridView.CurrentCellDirtyStateChanged (Evento)
Ensamblado: System.Windows.Forms (en system.windows.forms.dll)
Una celda se marca como modificada si su contenido ha cambiado y aún no se ha guardado el cambio.
Este evento suele producirse cuando se ha editado una celda y no se ha confirmado el cambio en la caché de datos, o cuando se cancela una operación de edición.
Para obtener más información sobre el control de eventos, vea Utilizar eventos.
En el ejemplo de código siguiente se muestra cómo controlar el evento CurrentCellDirtyStateChanged. En este ejemplo, el controlador de eventos llama al método CommitEdit para provocar el evento CellValueChanged y determinar el valor actual de un objeto DataGridViewCheckBoxCell. Este ejemplo de código forma parte de un ejemplo más extenso proporcionado en Cómo: Deshabilitar botones en una columna de botones del control DataGridView de formularios Windows Forms.
// This event handler manually raises the CellValueChanged event // by calling the CommitEdit method. void dataGridView1_CurrentCellDirtyStateChanged(object sender, EventArgs e) { if (dataGridView1.IsCurrentCellDirty) { dataGridView1.CommitEdit(DataGridViewDataErrorContexts.Commit); } } // If a check box cell is clicked, this event handler disables // or enables the button in the same row as the clicked cell. public void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Columns[e.ColumnIndex].Name == "CheckBoxes") { DataGridViewDisableButtonCell buttonCell = (DataGridViewDisableButtonCell)dataGridView1. Rows[e.RowIndex].Cells["Buttons"]; DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)dataGridView1. Rows[e.RowIndex].Cells["CheckBoxes"]; buttonCell.Enabled = !(Boolean)checkCell.Value; dataGridView1.Invalidate(); } }