Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Binding Combo and WinForm Synchonization
Message
From
15/03/2005 11:51:22
 
 
To
15/03/2005 10:32:03
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
VB.NET 1.1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
00995902
Message ID:
00995978
Views:
15
This message has been marked as the solution to the initial question of the thread.
Joe,

>Is there a way I can correct this OTHER than sorting the form's record source to match the dv.Sort?<

Yeah, it's not going to work the way you want it to without some additional code.

You don't have to use the DataTable's Default view, you can create a new DataView that's sorted by your CompanyID to find the row you're interested in. OK, so once you've found the index of that row in your DataView, then you'd need to iterate through the rows of your DefaultView to find the row that matches, and set the BindingContext .Position to that row's index.

I was going to say that if you need to iterate through the rows anyway, you might as well just skip the DataView and Find step, and just iterate through your rows in the DefaultView to find your CompanyID. But, then I had another idea. Try this on for size:

OK, so you find the index of the row in your new DataView that matches the CompanyID. Then, you find the CompanyName for that row. Then, do another .Find() for the CompanyName in your DefaultView and use that index to set the BindingContext .Position. Works like a charm (assuming that your CompanyName is unique, otherwise you'll only get a hit on the first one).

~~Bonnie





>THANKS for the feedback (I'll try using that information).
>Actually I was able to get the Postion working.
>
>PROBLEM: I want the form's data sorted by CompanyName and the data view sort must be by CompanyId in order to find a match.
>
>Using the following code (excerpted from original post), it successfully finds an index.
>However, because the sorting of the data is different the index does not resolve to the correct record
>
>Is there a way I can correct this OTHER than sorting the form's record source to match the dv.Sort?
>Is there a better way to synchronize the position other then by index number as Me.BindingContext(...).Position requires?
>
>' Set the Sort prop. with Col(s) to search [REQUIRED].
> dv.Sort = "CompanyId"
>
>' Set the index of the found row or -1 if not found
> intRow = dv.Find(companyIdSelected)
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform