I have this code :
private void vicationDataGridView_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (zawag) {
ComboBox cbo = e.Control as ComboBox;
if (cbo != null)
{
if (cbo.SelectedIndex == 6)
{
MessageBox.Show("test");
}
}
}
}
When I run my app, this code will not work untill I click the combobox 2 times and sometimes 3 clicks, I need to let it work for the first click when the user select value for the first time.
I tried to set the EditMode to EditOnEnter but the problem is not solved.
You need to use your DataGridView’s
EditingControlShowingevent to add an event handler for theSelectedIndexChangedevent of the ComboBox in your grid. You can move the code you have for testing the ComboBox’sSelectedIndexto the method that’s invoked when theSelectedIndexChangedevent fires.There’s a great example in MSDN.