I’ve been working on this for several hours now, I’m terrible with databinding, and I’m to the point that my frustration is probably actively blocking me from seeing an answer, so I’m backing off for a bit and hoping it’s obvious to someone else.
I’ve got three tables. Each are a set of groups. The layout is basically like this:
HEAD GROUP TABLE headGroupID headGroupNameSUB GROUP TABLE subGroupID subGroupName headGroupID
MEMBERS TABLE memberID memberName subGroupID
So head groups have sub groups, sub groups have members. Simple enough so far.
I’m trying to set up a set of three comboboxes that are databound to these tables and each other… the idea being only the subgroups of the selected group are shown in the subgroup combobox, and only the members of the selected subgroup are shown in the members combobox.
This is going horribly. I won’t even post any example code I’ve tried because it’s a gigantic hot mess of terrible failed attempts at databinding and datarelations and manually generating row arrays from select statement and the tears of children.
So.. what are inevitably the two lines of code I’m missing that will make all of this work?
What you’re describing is often referred to as a “cascading combobox” or “cascading drop-down list.” There are plenty of code samples if you know the right term to search for… (Sometimes it’s knowing the search term that’s the hard part.)
http://www.bing.com/search?q=cascading+combobox+c%23&go=&qs=n&sk=&sc=1-21&form=QBRE
One of the best articles on it is here: http://blogs.msdn.com/b/bethmassi/archive/2007/04/25/tips-on-related-data-binding-and-comboboxes.aspx?PageIndex=3