Beispiel #1
0
        private void UpdateButtons()
        {
            if (dataGridView1 == null || dataGridView1.IsDisposed)
            {
                return;
            }

            bool changed = false;

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                DataGridViewDisableButtonCell buttonCell =
                    (DataGridViewDisableButtonCell)row.Cells["Use"];

                bool old_val = buttonCell.Enabled;
                buttonCell.Enabled = (bool)row.Cells["Present"].Value;
                if (old_val != buttonCell.Enabled)
                {
                    changed = true;
                }
            }

            if (changed)
            {
                dataGridView1.Invalidate();
            }
        }
Beispiel #2
0
        // Override the Clone method so that the Enabled property is copied.
        public override object Clone()
        {
            DataGridViewDisableButtonCell cell =
                (DataGridViewDisableButtonCell)base.Clone();

            cell.Enabled = this.Enabled;
            return(cell);
        }
Beispiel #3
0
        private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            if (e.ColumnIndex == dataGridView1.Columns["Present"].Index)
            {
                DataGridViewDisableButtonCell buttonCell =
                    (DataGridViewDisableButtonCell)dataGridView1.
                    Rows[e.RowIndex].Cells["Use"];

                buttonCell.Enabled =
                    (bool)dataGridView1.Rows[e.RowIndex].Cells["Present"].Value;

                dataGridView1.Invalidate();
            }
        }