// 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 dgvInventoryStocks_CellValueChanged(object sender, DataGridViewCellEventArgs e) { if (dgvInventoryStocks.Columns[e.ColumnIndex].Name == "quantity") { DataGridViewDisableButtonCell buttonCell = (DataGridViewDisableButtonCell)dgvInventoryStocks. Rows[e.RowIndex].Cells["get_stock"]; int quantity = (int)dgvInventoryStocks[dgvInventoryStocks.Columns["quantity"].Index, e.RowIndex].Value; buttonCell.Enabled = (quantity < 1) ? true : false; dgvInventoryStocks.Invalidate(); } }