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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
Jorge PaulinoIT 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.