How to use combobox in datagrid

I have a datagrid created dynamically from a list (of object).   I would like one column to be of type combo box with the possible selections populated.  How is this accomplished?

codefingerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Jorge PaulinoConnect With a Mentor IT Pro/DeveloperCommented:

Oh, then you have to hide the column with the values, add the new DataGridViewComboBoxColumn and then loop on the DataGridView and set the proper value.
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
Hi,
You can use a DataGridViewComboBoxColumn. Something like this:

        Dim list As New List(Of String)
        list.AddRange(New String() {"a", "b", "c", "d"})

        Dim comboColumn As New DataGridViewComboBoxColumn
        comboColumn.DataSource = list
        Me.DataGridView1.Columns.Add(comboColumn)

Open in new window

0
 
Jorge PaulinoIT Pro/DeveloperCommented:
You can also use the Insert() method to specify the place where you want to add it.
Me.DataGridView1.Columns.Insert(0, comboColumn)

Open in new window

0
 
codefingerAuthor Commented:
Perhaps I misspoke....the datagrid is POPULATED dynamically, which means its columns are determined by the list of objects.   Adding a combocolumn to the grid after it is populated will just add an empty column to the ones already displayed.  So I need to be able to turn an existing and populated column into a combobox type column at run time.
0
 
codefingerAuthor Commented:
This looks like it is going to work and it is better than any of the complicated solutions I found via Google.  

Please see my related question to follow shortly.
0
All Courses

From novice to tech pro — start learning today.