View Single Post
  #2 (permalink)  
Old September 21st, 2010, 12:03 PM
rodmarquez21 rodmarquez21 is offline
Registered User
 
Join Date: Sep 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Talking 4 years after...

Hi, I'm facing the same problem, and figured out that adding a line that substracts the event evertime it enters to the method event-catcher will fix the problem. this is my code:

private void dgConceptos_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
DataGridView dataGridView = (DataGridView)sender;
ComboBox comboBox = new ComboBox();
if (dataGridView.CurrentCell.ColumnIndex == 0)
{
comboBox = e.Control as ComboBox;
if (comboBox != null)
{
comboBox.SelectedIndexChanged -= new EventHandler(dgConceptosComboBoxDescripcion_Select edIndexChanged);
comboBox.SelectedIndexChanged += new EventHandler(dgConceptosComboBoxDescripcion_Select edIndexChanged);
}
}

}

private void dgConceptosComboBoxDescripcion_SelectedIndexChange d(object sender, EventArgs e)
{
ComboBox comboBox = (ComboBox)sender;

if (!string.IsNullOrEmpty(comboBox.Text))
{
some code here...
}
comboBox.SelectedIndexChanged -= new EventHandler(dgConceptosComboBoxDescripcion_Select edIndexChanged);
}
Reply With Quote