|
-
Dec 5th, 2010, 05:03 AM
#1
Thread Starter
Hyperactive Member
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?
-
Dec 5th, 2010, 06:43 AM
#2
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.
-
Dec 5th, 2010, 09:33 AM
#3
Thread Starter
Hyperactive Member
Re: BindingSource.Position issue
I would like to set the position before binding. how can i do that?
-
Dec 5th, 2010, 05:49 PM
#4
Re: BindingSource.Position issue
 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).
-
Dec 6th, 2010, 08:38 AM
#5
Thread Starter
Hyperactive Member
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)
-
Dec 6th, 2010, 06:01 PM
#6
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).
-
Dec 7th, 2010, 08:07 AM
#7
Thread Starter
Hyperactive Member
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)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|