Hello all,
I have a problem binding a combobox in a windows form, what i'm trying to do is the following:

I need to bind the combobox to a column (ex: customerID) in a dataset. this column is a foreign key.
howerver, I want the datasource of the combobox to be the list of customer names in another table that consists of customer names and ids.

i'm setting the bindings property of the combobox to the proper column in the dataset, and from the code i'm doing the following:

comboBox1.DisplayMember = ds.Tables["tableName"].Columns["customerName"].ColumnName.ToString();

comboBox1.ValueMember = ds.Tables["tableName"].Columns["customerId"].ColumnName.ToString();

comboBox1.DataSource = ds.Tables["tableName"];

I'm using a binding navigator, running the previous code at form load, I can navigate through the records correctly, the combobox displays customernames corresponding to ids. however when I try to insert a new record I choose customer name from the list but then the cursor is trapped in the combobox and i can't move to any other field unless I type an id in the combobox!!

Can anybody help me with this please?

Have you bind a combo? Please show us that code.

Have you bind a combo? Please show us that code.

Thank you for your reply..
I did bind the combo but in design not through the code. I have set the binding property of the combobox to the required column in the binding source and also set the selectedvalue property to the same column.

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.