// 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); }
private void setRepairBtnDisable() { for (int i = 0; i < dataGridView1.RowCount; i++) { DataGridViewDisableButtonCell btnCell = dataGridView1.Rows[i].Cells["ActionCol"] as DataGridViewDisableButtonCell; if (dataGridView1.Rows[i].Cells["StatusCol"].Value.ToString() == MaintainDeclare.RepairFinished) { btnCell.Enabled = false; } } }
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dataGridView1.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex > -1) { DataGridViewDisableButtonCell btnCell = dataGridView1.CurrentCell as DataGridViewDisableButtonCell; if (dataGridView1.Rows[e.RowIndex].Cells["StatusCol"].Value.ToString() == MaintainDeclare.RepairFinished) { btnCell.Enabled = false; return; } if (btnCell != null) { ToolSerialName = getSerialNumFromGrid(); Status = getStatusFromGrid(); RepairOperatorForm repairOperatorForm = new RepairOperatorForm(); if (repairOperatorForm.ShowDialog() == DialogResult.OK) { btnSearch_Click(sender, e); Show(); } } } }