Bindingsource.Current one record behind

mc103

New member
Joined
Sep 19, 2008
Messages
3
Programming Experience
Beginner
Hi everyone

I'm trying to perform a remarkably simple operation, and even though I've solved it using an alternative method, I was hoping someone might be able to answer this question.

I have a combobox bound to a Customer table that displays the customer codes. When I change the value in the combobox, I want to populate an unbound textbox with the Customer Name.

Now, when I change the combobox value, it does change the textbox value, but it's always one record behind. It displays the CustomerName relating to the combobox value I just changed from.

Using the Changed Index event on the combo box, I run some code such as :

Dim drvRow As DataRowView
Dim drRow As DataRow

drvRow = TblCustomerBindingSource.Current

drRow = drvRow.Row

lblInfo.Text = drRow("CustomerName")

No doubt there is some very obvious explanation to this, but I sure can't find it. Any help would be greatly appreciated, Thanks.
 
The combobox.selected index isnt fully selected even though you added a new text value.

Add:

ComboBox.SelectedIndex = ComboBox.FindString(ComboBox.Text)
 
Youre using a -ing event rather than an -ed event

-ing events occur before the relevant actions
-ed occur after

TextChanging/TextChanged.


Given that youre getting the data from the bindingsource (correct), why dont you hook one of the events that the binding sourceraises when it changes its position or its current item?

Or better still, just bind the text box!
 

Latest posts

Back
Top