I am setting up a DataGridViewComboBoxColumn like this:
var newColumn = new DataGridViewComboBoxColumn() {
Name = "abc"
};
newColumn.DataSource = new string[] { "a", "b", "c" };
dgv.Columns.Add(newColumn);
This works: each row has a dropdown box in that column, populated with a, b, c.
However, now I would like to trim the list for certain rows. I'm trying to set the list per row like this:
foreach (DataGridViewRow row in dgv.Rows) {
var cell = (DataGridViewComboBoxCell)(row.Cells["abc"]);
cell.DataSource = new string[] { "a", "c" };
}
However, this code has no effect - every row still shows "a", "b", "c".
I have tried replacing new string[] with new List<string> and new BindingList<string>, both to no avail.
I also have tried removing the code that sets newColumn.DataSource, but then the lists are empty.
How should I go about doing this properly?