title: c# add a dgv row with a dataGridViewComboBoxCell
body: <p>I'm currently trying to add a ComboBox to a dataGridView.</p>
  
  <p>In the DGV, there are 5 columns: checkbox, string, string, combobox, combobox.</p>
  
  <p>both combobox-columns are configured as datagridviewcomboboxcolumns (via VisualStudio designer). My problem is to add rows.</p>
  
  <p>My current try is: the columns are already defined and I add rows via dataGridView.Rows.Add.
  For that, I'm using an array of objects. Example:</p>
  
  <pre><code>dataGridViewRow row = new dataGridViewRow();
  object[] obj = new object[5] {true, "str1", "str2", null, null};
  dataGridView1.Rows.Add(obj);
  </code></pre>
  
  <p>This passes without any errors. But logically, the comboBoxes aren't filled with anything.</p>
  
  <p>I tried setting a datasource to the 4th and 5th cell of a row:</p>
  
  <p>Error...Using ROW.dataGridViewComboBoxCell.Items.Add: Items are not displayed...</p>
  
  <p>filling obj[3] and 4 with a new DGVcomboBoxCell or -Column:</p>
  
  <pre><code> Error... :The error message says "The dataGridViewComboBoxCell-Value is invalid.
  </code></pre>
  
  <p>Further information: Each column should have the same Items in the comboBoxes. (These are previously loaded via internet, as xml). Setting a dataSource to the two columns destroys the whole DGV (I think because the other colmns don't have a Datasource).
  In a nutshell: How to add Rows to a DGV which contain comboboxes filled with items?</p>
  
  <p>Sincerely,
  NoMad</p>
  
  <p>edit: here's some code to solve my problem:</p>
  
  <pre><code>        DataGridViewCheckBoxColumn check = new DataGridViewCheckBoxColumn();
          check.Name = "Col1";
          dataGridView1.Columns.Add(check);
  
          dataGridView1.ColumnCount = 3;
          dataGridView1.Columns[1].Name = "Col2";
          dataGridView1.Columns[2].Name = "Col3";
  
          object[] row = new object[] { true, "str1", "str2" };
          dataGridView1.Rows.Add(row);
  
          DataGridViewComboBoxColumn combo1 = new DataGridViewComboBoxColumn();
          DataGridViewComboBoxColumn combo2 = new DataGridViewComboBoxColumn();
  
          combo1.Name = "Col4";
          combo1.Items.Add("100x100");
          combo1.Items.Add("200x200");
  
          combo2.Name = "Col5";
          combo2.Items.Add("option1");
          combo2.Items.Add("option2");
  
          dataGridView1.Columns.Add(combo1);
          dataGridView1.Columns.Add(combo2); 
  </code></pre>
  
  <p>First add a row, cast  columns, configure them and add them to the row.
  No Columns need to be previously specified in the designer.</p>