Reputation: 1
I have a a DataGridView which has a list assigned as a datasource and that list contains objects, in that list I have a List which contains objects and this object has a 'name' field. I created an unbound column with a type of DataGridViewComboBoxColumn. I want to add the name field mentioned before to the ComboBox.
I want to do something similar to that:
paymentTable.Rows[i].Cells[6].Items.Add(cn.name);
but this is not possible because, this way I'm going to get a DataGridViewCell type.
Upvotes: 0
Views: 35
Reputation: 27
You have to specify the column type as a DataGridViewComboBoxColumn
var relatedColumn = (DataGridViewComboBoxColumn)paymentTable.Columns[0];
// 0 is your name column index
relatedColumn.Items.Add("New Item");
Upvotes: 0