I'd like to add new column to existing datagridview so:
DataColumn col = new DataColumn(( dataGridView1.ColumnCount+1).ToString());
dataGridView1.Columns.Add(col);
But it doesn't work.. how to do it?
I think that you need to specify what type of cell the column will contain.
For example:
DataGridViewColumn newCol = new DataGridViewColumn(); // add a column to the grid
DataGridViewCell cell = new DataGridViewCell(); //Specify which type of cell in this column
newCol.CellTemplate = cell;
newCol.HeaderText = "test2";
newCol.Name = "test2";
newCol.Visible = true;
newCol.Width = 40;
gridColors.Columns.Add(newCol);
DataGridViewCell is abstract, now. Use DataGridViewCell cell = new DataGridViewTextBoxCell(); for example.