I have a DataGridView object. Elsewhere in the program, I want to create code which does something like this:
-
DataGridViewColumn col = new DataGridViewColumn();
-
listBox1.Items.Add(col);
And then subsequently add it to the DataGridView later. Unfortunately, when I try this, adding it to the DataGridView throws an exception because "At least one of the DataGridView control's columns has no cell template." How can I do this?