title: How to rebind datasource to a winform DataGridView Combobox column?
body: <p>I have a DataGridView in winform with 2 combo box columns: 1) Companies, 2) Accounts.
  I want to update the accounts combo box according to the selected company.
  I have this code:</p>
  
  <pre><code>void recipientsDataGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
      {
          try
          {
              ComboBox cb = e.Control as ComboBox;
              if (cb != null)
              {
                  cb.SelectedValueChanged -= new EventHandler(companyCombobox_SelectedValueChanged);
                  cb.SelectedValueChanged += new EventHandler(companyCombobox_SelectedValueChanged);
              }
          }
          catch (Exception ex)
          {
  
          }
      }
  
      private void companyCombobox_SelectedValueChanged(object sender, EventArgs e)
      {
          try
          {
              var currentCell = recipientsDataGrid.CurrentCellAddress;
              if (currentCell.X == 3)
              {
                  var sendingCB = sender as DataGridViewComboBoxEditingControl;
                  int companyId = sendingCB.SelectedValue.ToInt();
                  DataTable dtAccounts = m_CustomersFunctions.GetCompanyAccounts(companyId);
  
                  DataGridViewComboBoxCell cboAccounts = (DataGridViewComboBoxCell)recipientsDataGrid.Rows[currentCell.Y].Cells["Account"];
                  cboAccounts.ValueMember = "account_id";
                  cboAccounts.DisplayMember = "AccountName";
                  cboAccounts.DataSource = dtAccounts;
  
                  int defaultAccountId = (from row in dtAccounts.AsEnumerable()
                                          where row.Field&lt;string&gt;("AccountName").EndsWith("*")
                                          select row.Field&lt;int&gt;("account_id")).FirstOrDefault();
                  if (defaultAccountId &gt; 0)
                      cboAccounts.Value = defaultAccountId;
              }
          }
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
      }
  </code></pre>
  
  <p>It works fine in the first time I select a company, but when I change the company and try to update the data source for the accounts combo box I'm getting an error:</p>
  
  <p><img src="https://i.stack.imgur.com/gck3B.png" alt="enter image description here"></p>
  
  <p>I tried to add the items manualy and not with a DataSource, and I got the same error.
  How can I fix it ?
  please...</p>