Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Synchronizing a Combobox to the Record

Status
Not open for further replies.

scking

Programmer
Jan 8, 2001
1,263
US
I've used .NET comboboxes which are bound using the DisplayMember, ValueMember, and SelectValue set. These display all values from a validation table. I would like to be able to select values synchronized to the record. So, for a specific Project code it would select ONLY those verions that can be associated to that project. I could use some advice on this implementation. I'm relatively new to .NET database applications.

tblProject.ProjName.Value='ASPAPP'
tblVerions.VersionID='1.0.0', tblVersions.ProjName='ASPAPP'
tblVersions.VersionID=1.0.1', tblVersions=ProjName='ASPAPP'

---------------------
scking@arinc.com
---------------------
 
Hi,

What I do is create custom classes to hold an item's data I also create collections to hold these items.

Using a For Each loop I iterate collection A. and populate the Combobox. When the user changes the selection I can then get their selection and iterate collection B. to fill another combobox with items from the collection that meets their selection.
Code:
Dim XX as CollectionOfXXs = New CollectionOfXXs()
Dim YY as CollectionofYYs = New CollectionOfYYs()

For Each I as XXItem in XX
    ComboboxXX.Items.Add(I)
Next

SelectedIndexChanged On ComboBoxXX
Dim I as XXItem = CType(ComboboxXX.SelectedItem, XXItem)
For Each Z as YYItem in YY
    If (I.ID() = Z.ID()) Then
        ComboBoxYY.Items.Add(Z)
    End If
Next
This psuedo should give you an idea of what I mean. Hope this helps, but if you need further clarification then let me know.


 
I had this in the back of my mind but was expecting (read hoping) for a simpler method, maybe using databindings. I'm going to implement this and appreciate your comment.

---------------------
scking@arinc.com
---------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top