Ejemplo n.º 1
0
        private void DGV_CurrentCellDirtyStateChanged(object sender, EventArgs e)
        {
            // Immediately handle changes of the Blended Checkbox - workaround the regular DGV behavior
            if (!DGV.IsCurrentCellDirty)
            {
                return;
            }
            if (DGV.CurrentCell.ColumnIndex != DGV.Columns["Disabled"].Index)
            {
                return;
            }

            // only if dirty and the Blended column ..
            // it still has it's previous value i.e. inverse the logic here - commit the value imediately
            if ((bool)DGV.Rows[DGV.CurrentCell.RowIndex].Cells[DGV.Columns["Disabled"].Index].Value == false)
            {
                DGV.Rows[DGV.CurrentCell.RowIndex].Cells[DGV.Columns["Disabled"].Index].Value = true; // toggle value - triggers the ValueChanged Event below
            }
            else
            {
                DGV.Rows[DGV.CurrentCell.RowIndex].Cells[DGV.Columns["Disabled"].Index].Value = false;
            }
            DGV.NotifyCurrentCellDirty(false); // have set the value - so set not dirty anymore
        }