I know how to add the items during design time but how do you add the items through code. I want to fill the combo box in the datagrid with the results of an SQL query?

Recommended Answers

All 3 Replies

I know how to add the items during design time but how do you add the items through code. I want to fill the combo box in the datagrid with the results of an SQL query?

you're going to have to create an array to store the results from the sql query.

In the method where the sql query is executed populate the array using a while loop. (while there is data in the query).

then in your method where you want to populate the combo box. Just run a for loop that takes an item from the array and adds it to the combo box.

you can find all the code to do this online. Hope this helps

That what I need is the code. It is not the same as a combo box since the combo box is in the datagridview. First I have to add the row then popuplate the column of the row that contains the combo box.

I am going to be working on this in a project that I am working on soon. As soon as I know I will let you know... I will probably be working on it a little tonight so will try and have a reply for you soon!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.