You can use the DataSource
to feed to Items
, but using a simple string array will not work.
Instead you can convert the array to a List<string>
:
string[] datasource = { "add1", "add2" };
DataGridViewComboBoxCell combo = new DataGridViewComboBoxCell();
combo.DataSource = datasource.ToList();
DGV.Rows[2].Cells[2] = combo;
To set a value you can use..
combo.Value = combo.Items[0];
..after having set the cell.
For better control, especially for having spearate Display
- and ValueMembers
you can switch to a Dictionary
or use a List<someClass>
..
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…