• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 747
  • Last Modified:

VB.net Programatically add a ComboBox column

Hi

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

Thanks
0
Murray Brown
Asked:
Murray Brown
  • 2
  • 2
1 Solution
 
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.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now