EditingControlShowing in DataGridView w 2 combobox
Hello fellow programmers,
I have a dataGridView with 2 comboBoxColumns amongst simple textboxColumns. When I click on the combo in column 4 everything is good grid_EditingControlShowing is called and rawComboChanged is called after it.
But when i then click on column 11, rawComboChanged is called immediately, skipping the call to grid_EditingControlShowing that should point the code towards currencyChanged method.
I think i found the problem: "The DataGridView reuses editing controls across cells if the type is the same"... But i dont have a solution... Can anyone help?
public void grid_EditingControlShowing(object sender, System.Windows.Forms.DataGridViewEditingControlSho wingEventArgs e)
{
DataGridView dataGridView = (DataGridView)sender;
ComboBox comboBox = new ComboBox();
if (dataGridView.CurrentCell.ColumnIndex == 4)
{
comboBox = e.Control as ComboBox;
comboBox.SelectedIndexChanged += new System.EventHandler(this.rawComboChanged);
}
else if (dataGridView.CurrentCell.ColumnIndex == 11)
{
comboBox = e.Control as ComboBox;
comboBox.SelectedIndexChanged += new System.EventHandler(this.currencyChanged);
}
}
Mike
|