View Single Post
  #1 (permalink)  
Old September 28th, 2006, 10:57 AM
mike_geomatics mike_geomatics is offline
Registered User
Join Date: Sep 2006
Location: london, , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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);

Reply With Quote