public CustomDGVButtonColumn() { CustomDGVButtonCell obj = new CustomDGVButtonCell(); this.CellTemplate = obj; CellTemplate = new CustomDGVButtonCell(); }
// Override the Clone method so that the Enabled property is copied. public override object Clone() { CustomDGVButtonCell cell = (CustomDGVButtonCell)base.Clone(); cell.Enabled = Enabled; return(cell); }
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex > -1) { CustomDGVButtonCell cell = (CustomDGVButtonCell)dataGridView1.Rows[e.RowIndex].Cells[1]; if (e.ColumnIndex == 1 && cell.Enabled) { try { MessageBox.Show(cell.Value.ToString()); } catch { } } } }