Question combobox datasource

jamie123

Well-known member
Joined
May 30, 2008
Messages
82
Programming Experience
Beginner
I have a datagridview linked to a bindingsource that doesn't include the table i want my combobox (which is in my datagridview) to be databound to. Is there anyway to specifically identify each column's datasource in a dgv? I would like this combobox's datasource to be a column in a table included in the same dataset as the datagridview's source, but not in the same tableadapter. Is there anyway to include columns from other tables into one tableadapter maybe?
 
Yes, that's the idea of comboboxes, they are used as lookups.

With Combobox1
.datasource = CustomerBindingSource
.displaymember = "CustomerName"
.valuemember = "CustomerID"
.databindings.add("SelectedValue", OrdersBindingSource, "CustomerID")
End With

^ So for the Orders table, the CustomerID field will show the customer name in the combobox instead....
 
maybe i wasn't clear really, this is what i want to do.

I have a datagridview that pulls data from one datasource

But, I want users to be able to modify the selections on the datagridview itself, the selections for each row come from a different datasource

For example, if the financial table has 1 row and 1 column, let's call the column salary, i pull the data from the financial table into the datagrid view and that 1 record has a salary of 50,000. Now, another table called SalaryOptions has 4 different values that you can assign to the salary column in the financial table. I want the salary column to be a combo box and PULL/SAVE from/to the financial table, but be able to list options from the SalaryOptions table, i hope that makes sense:confused:
 
example

You have a DGV that shows tblPerson, but instead of "Mr", "Mrs" etc you have ID numbers 1, 2..
And another table tblPersonTitle where:
1=Mr
2=Mrs

And you wanna see Mr, Mrs etc in a combo on the DGV but you want it to edit and store the ID values 1, 2, etc into tblPerson?
See attached
 

Attachments

  • cjard_does_datagridviewcombobox.zip
    145.1 KB · Views: 24

Latest posts

Back
Top