// 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 dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) { int code = (int)dataGridView1.Rows[e.RowIndex].Cells["code"].Value; //openbox if (e.ColumnIndex == 5) { bool issuccess = bm.Find(code).Open(); //MessageBox.Show(issuccess.ToString()); UpdateData(); } //删包裹 if (e.ColumnIndex == 6) { DataGridViewDisableButtonCell btnCell = (DataGridViewDisableButtonCell)dataGridView1.Rows[e.RowIndex].Cells["deletePackage"]; if (btnCell.Enabled) { bool issuccess = pm.TakePackage(code, 2); //MessageBox.Show(issuccess.ToString()); UpdateData(); } } //disable box if (e.ColumnIndex == 7) { //DataGridViewDisableButtonCell btnCell = (DataGridViewDisableButtonCell)dataGridView1.Rows[e.RowIndex].Cells["open"]; if (bm.Find(code).CurrentState == Box.State.Fault) { bm.DisableBox(code); //btnCell.Enabled = true; UpdateData(); } else { bm.EnableBox(code); UpdateData(); } } }