Hi, I want to handle this event "SelectedIndexChanged" on a DataGridViewComboBoxColumn, and I set it on "EditingControlShowing" event of the gridview. and the problem : "SelectedIndexChanged"event is not fired on first attempt of selecting an Item from the comboBox, but after selecting that item for the second time the event is fired and everything works fine !
here is the code:
private void dgvRequest_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
ComboBox combo = e.Control as ComboBox;
if (combo != null)
{
if (dgvRequest.CurrentCell.ColumnIndex == col_ConfirmCmb.Index)
{
combo.SelectedIndexChanged -= combo_ConfirmSelectionChange;
combo.SelectedIndexChanged += combo_ConfirmSelectionChange;
return;
}
}
}
void combo_ConfirmSelectionChange(object sender, EventArgs e)
{
if (dgvRequest.CurrentCell.ColumnIndex != col_ConfirmCmb.Index) return;
ComboBox combo = sender as ComboBox;
if (combo == null) return;
MessageBox.Show(combo.SelectedText);// returns Null for the first time
}