BindingSource.Position issue
Hi,
I am using the following code to populate data in Textbox1:
Code:
Me.OrdersTableAdapter.Fill(Me.OrderBookingDataSet.Orders, Master.c)
Me.OrdersBindingSource.Position = OrdersBindingSource.Find("ord", Master.o)
I have few functions assigned in TextBox1_TextChanged event. The problem i am facing is this event is fired twice, once after the Fill command and another after the Position command whereas i want the event to fire only once after the Position command. What should i do?
Re: BindingSource.Position issue
You should either not bind until after setting the Position or else ignore the first event. If you want to ignore the first then you must know that it's the first event, which would require a Boolean flag. Set it first, then reset it afterwards.
Re: BindingSource.Position issue
I would like to set the position before binding. how can i do that?
Re: BindingSource.Position issue
Quote:
Originally Posted by
LuxCoder
I would like to set the position before binding. how can i do that?
Set the Position property first, then bind the BindingSource to the control(s).
Re: BindingSource.Position issue
This doesn't work.
Code:
Me.OrdersBindingSource.Position = OrdersBindingSource.Find("ord", Master.o)
Me.OrdersTableAdapter.Fill(Me.OrderBookingDataSet.Orders, Master.c)
Re: BindingSource.Position issue
Of course that doesn't work. You're trying to set the Position before you've populated the DataTable. If you haven't populated the DataTable with data then how can you Find anything in the data it contains? Populate the DataTable, bind the DataTable to the BindingSource, set the Position, bind the BindingSource to the control(s).
Re: BindingSource.Position issue
This works :)
Code:
RemoveHandler TextBox1.TextChanged, AddressOf TextBox1_TextChanged
Me.OrdersTableAdapter.Fill(Me.OrderBookingDataSet.Orders, Master.c)
AddHandler TextBox1.TextChanged, AddressOf TextBox1_TextChanged
Me.OrdersBindingSource.Position = OrdersBindingSource.Find("ord", Master.o)