Creating a column for a DataGridView without inserting it immediately

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Falkeli
    New Member
    • Feb 2012
    • 19

    Creating a column for a DataGridView without inserting it immediately

    I have a DataGridView object. Elsewhere in the program, I want to create code which does something like this:
    Code:
    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?
Working...