Sometimes we need to generate events for the controls, which were in DataGridview.
Let us assume we have Checkbox and Combobox in a DataGridView(say dataGridView1)
Now I want to generate events to those columns.
Here is the way to generate events.
We can use EditingControlShowing event of datagridview
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
ComboBox comboCell = e.Control as ComboBox;
if (comboCell != null)
comboCell.DropDownStyle = ComboBoxStyle.DropDownList;
comboCell.SelectedIndexChanged -= new EventHandler(comboCell_SelectedIndexChanged);
comboCell.SelectedIndexChanged += new EventHandler(comboCell_SelectedIndexChanged);
CheckBox ck = e.Control as CheckBox;
if (ck != null)
ck.CheckedChanged += new EventHandler(ck_CheckedChanged);
Implement your functionality in that events
More articles: DataGridView