Editing/Loading/Finding the DataGridViewComboBoxColumn.Items Property?

SuperSpy

New member
Joined
Jan 2, 2007
Messages
1
Programming Experience
1-3
I have an application that uses a DataGridView with one column a DataGridViewComboBoxColumn. I can edit the Items Property via the built-in editor to define what is in the drop-down. But I can't work out how to find that property while the program is running, as the application needs to load it from external configuration.

Does anyone know how to find this property at run-time?
 
Cast the cell to the type DataGridViewComboBoxCell, with this strong type cell object you can set the Items property or DataSource property.
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dgvcbc [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataGridViewComboBoxCell[/SIZE]
[SIZE=2]dgvcbc = [/SIZE][SIZE=2][COLOR=#0000ff]DirectCast[/COLOR][/SIZE][SIZE=2](DataGridView1.Item(0, 0), DataGridViewComboBoxCell)[/SIZE]
Same goes for Column where you can set items for all comboboxes in column.
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dgvcbcolumn [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataGridViewComboBoxColumn[/SIZE]
[SIZE=2]dgvcbcolumn = [/SIZE][SIZE=2][COLOR=#0000ff]DirectCast[/COLOR][/SIZE][SIZE=2](DataGridView1.Columns(0), DataGridViewComboBoxColumn)[/SIZE]
I used column by integer index here, but you can also access it by string name index.
 
Back
Top