Hi guys,
Just wondering if there was a way of populating a DataGridView control during runtime so that in one column there could be a few rows set to type string followed by a combobox control cell all in the same column?
Thanks
Printable View
Hi guys,
Just wondering if there was a way of populating a DataGridView control during runtime so that in one column there could be a few rows set to type string followed by a combobox control cell all in the same column?
Thanks
No! Nor indeed at any time.
Yes that is completely possible and, in fact, at run time is the only time you can do it. When you add columns to a DataGridView you are specifying the template cell type for that column but, in fact, any cell in any column can be any type you want. You simply create a cell of the type you want and assign it to the grid's Item property, which gets or sets the cell at particular column and cell coordinates, e.g.That will put a combo box cell in the second column of the sixth row regardless of the type of that column. The cell that was at that location will be discarded.Code:DataGridView1(1, 5) = New DataGridViewComboBoxCell()
Brilliant, works a charm thanks.
You can? Darn it! Just when you think that darned DGV straight in your head ....