Asif Huddani

Asif Huddani

  • NA
  • 1
  • 2.3k

Datagrid View colboboxcloumn event problem

Apr 19 2010 2:38 AM
Hello,

I have datagridview on my form having 2 combobox.
One for Country and another for state.
I handle event for both combobox..
When i click on country combobox then it's selected change commited event fire and fill state. working properly...

But when i click on state then also country column event fire and reload the state column.

Please help me.......


private void dgvContactDetail_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{

switch (dgvContactDetail.CurrentCell.ColumnIndex)
{

case 1:
{
var cb = (ComboBox)e.Control;
cb.SelectionChangeCommitted -= new EventHandler(countryComboBox_SelectionChangeCommitted);
cb.SelectionChangeCommitted += new EventHandler(countryComboBox_SelectionChangeCommitted);
}
break;
case 2:
{
var cb = (ComboBox)e.Control;
cb.SelectionChangeCommitted -= new EventHandler(stateComboBox_SelectionChangeCommitted);
cb.SelectionChangeCommitted += new EventHandler(stateComboBox_SelectionChangeCommitted);
}
break;
default:
break;
}
}

private void countryComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
// Fill State Combo
}


private void stateComboBox_SelectionChangeCommitted(object sender, EventArgs e)
{
// Fill City

}

Thanks,
Asif Huddani
http://asifhuddani.wordpress.com

Answers (1)