Winforms Data Binding Lessons Learned

My blog has moved.
You can view this post at the following address:
http://www.osherove.com/blog/2003/6/21/winforms-data-binding-lessons-learned.html
Published Saturday, June 21, 2003 10:12 PM by RoyOsherove
Filed under:

Comments

Saturday, June 21, 2003 3:50 PM by Dave Burke

# re: Winforms Data Binding Lessons Learned

Roy, this post is in my "Gold" folder and I will definitely be going back to it. Thanks.
Saturday, June 21, 2003 6:12 PM by TrackBack

# ISerializable

ISerializable
Saturday, June 21, 2003 8:10 PM by Roy Osherove

# re: Winforms Data Binding Lessons Learned

:)
Saturday, June 21, 2003 9:17 PM by Paul Gielens

# re: Winforms Data Binding Lessons Learned

Nice share Roy, appreciate it!
Wednesday, August 20, 2003 9:37 AM by Ruebs

# re: Winforms Data Binding Lessons Learned

Excellent stuff on the delete cancellation in a datagrid. i have been searching for info for many days now. Thanks.
Tuesday, December 02, 2003 4:24 AM by llar

# re: Winforms Data Binding Lessons Learned

Hi,
This is a very useful solution. but i don't get the keydown events fired from datagrid. please help me out?
LLara
Friday, February 13, 2004 6:16 AM by Rutger

# re: Winforms Data Binding Lessons Learned

Thank you,

Please get a job at Microsoft...
Wednesday, March 03, 2004 7:37 PM by Kat

# re: Winforms Data Binding Lessons Learned

Unfortunately this solution only works when your displayed sort order matches your tables primary key.

ie: If my customer table has a pk called "ID" but the navigational order for the client is by "Name" (and supports duplicate entries) then this solution fails since there is no way to map the binding position returned in a dataview sorted by ID to the binding position of the table (or another dataview) sorted by NAME.

This has bee a source of great frustration for me since the .NET platform seems to have no mechanism for moving the binding position of a table to the location of a datarow returned in a [datatable].rows.find().

The only workaround I've come up with is to create a hidden combobox called lbGetIndexOf whose datasource is bound to the table and whose display and valumenbers are bound to the tables primary key. I can then sync the binding position by doing a:

bm.position = lbGetIndexOf.FindStringExact(key)
Wednesday, March 03, 2004 7:38 PM by Kat

# re: Winforms Data Binding Lessons Learned

err: thats a hidden LISTBOX not combobox - although either control would work
Wednesday, August 02, 2006 9:43 PM by John

# re: Winforms Data Binding Lessons Learned

does lesson 4 apply to my scenario? I have also started using the BindingSource with great success. I have a scenario that I did find though, that seemed a limitation. I have Patients->Theatre->Procedure set up with the arrow head meaning the many of a 1 to many. So a Patient is selected, I bind the Theatre DataSource and the first row of the Theatre data is show correctly - cool. Unfortunately any controls like say a Procedure Type Combo do *not* have their selected value set correctly (despite doing the right thing in advanced binding settings ie procedure1Combo selected value bound to the FK in the theatre DataSource. I think it may be a limitation in that the Patient is the 3rd link in the chain so to speak and does not pick up the change in binding source.......still investigating. Maybe I have to check out the BindingManager a bit more?