Selecting a value in a bound combobox?

M

Magnus Bergh

I thought this was easy, just to SelectedValue in code for example
Combobox1.SelectedValue= "ABC". Looks on screen like it works and the
correct value shows in the combobox but the underlying datasource is not
updated.

It is like the usual order entry example where you have a combox
displaying customer names and selectedvalue bound to the order's
customerid and valuemember to customer id of customer bindingsource. So
what I want to do is to select the correct customer in the combobox
using the customer id.

What I did was instead to use the bindingsource.find method and set
position in bindingsource which seems to work fine.

For example:

index=CustomerBindingSource.Find("CustomerId", customerid)
if index <> -1 then CustomerBindingSource.Position= index

where customerid is the id of the customer I want to find.

Is this the correct method to do this?
 
G

Guest

don't you have to have a line like
customerBindingSource.endedit()
to "apply pending changes to the underlying datasource" ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top