VB.net Programatically add a ComboBox column

Hi

In VB.net how do I programatically add a ComboBox column?

Thanks
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAsked:
Who is Participating?
 
nepaluzCommented:
Add a new column
Me.DataGridView1.Columns.Add(New DataGridViewComboBoxColumn With {.DataSource = {"First", "Second", "Third"}})

Open in new window

insert new column
Me.DataGridView1.Columns.Insert(0, New DataGridViewComboBoxColumn With {.DataSource = {"First", "Second", "Third"}})

Open in new window

0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Hi. These aren't bound columns and I hold the names in array of over two hundred items. I need to loop through and add a ComboBox column for each string in my array arrColumns
0
 
nepaluzCommented:
What exactly do you mean that these are not bound columns? Is it that you want to add bound comboboxcolumns to an existing grid or that you want to add columns to a grid that is bound to a datasource?

The examples above will programatically add a datagridviewcomboboxcolumn to a datagridview with a choice of inserting it (the column) at your desired location or adding it to the end, (just like you asked).

Please clarify what you mean.
0
 
Murray BrownMicrosoft Cloud Azure/Excel Solution DeveloperAuthor Commented:
Thanks. My mistake. Your answer was just what I needed
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.