Reputation: 1207
I am trying to insert a row into a DataGridView programmatically. The columns are:
Column1 combobox
Column2 textbox
This is my code. Column1 is bound to a table using the built-in DataSource of DataGridView.
DataGridViewRow row = new DataGridViewRow();
DataGridViewComboBoxCell __action1 = new DataGridViewComboBoxCell();
DataGridViewTextBoxCell __site = new DataGridViewTextBoxCell();
__action.Value = 1; //1 is id.
__sitetype.Value = "google.com";
but this gives me an error of "DataGridViewComboBoxCell invalid value." How do I fix this?
Upvotes: 1
Views: 5702
Reputation: 1302
DataGridViewRow dr = new DataGridViewRow();
DataGridViewCell dcDescription = new DataGridViewTextBoxCell();
dcDescription.Value = "some text";
dr.Cells.Add(dcDescription);
dataGridViewDoctorEventsAddServices.Rows.Add(dr);
Upvotes: 2