Getting Collection values via Listbox Index Change

blaketheturtle

New member
Joined
Jul 31, 2006
Messages
1
Programming Experience
Beginner
Hi. I just found these forums and I hope you will be able to help me. I've posted on the vb.net newsgroup and haven't gotten a response and I've worked on the code for a couple of hours as well...to no avail. I've only been working w/ VBnet for 2 weeks.

I have two listboxes. Listbox1 contains collections. Selecting an item
in listbox1 and pressing a control button sends the collection to
Listbox2. When the item is selected in Listbox2 it you are able to edit the
collections properties via textboxes that appear using the
flowlayoutpanel.

All of this works fine as long as the same collection doesn't appear
twice in Listbox2. For instance if Listbox1 contains the collection
Spices and Sweetners for use in a recipe, if Spices appears in Listbox2
more than once (i.e. using more than one spice in the recipe) the
values entered for one spice collection are copied to every other spice
collection in Listbox2. I want to be able to have two collections of
the same type in Listbox2 with each being able to have their own unique
values.

I think the problem is in Sub ListBox2_SelectedIndexChanged

Here is my code:

************** Begin Code **************
VB.NET:
Expand Collapse Copy
Private Sub ListBox2_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListBox2.SelectedIndexChanged
Dim ingredient As ingredientlist
ingredient = Me.ListBox2.SelectedItem
FlowLayoutPanel1.Controls.Clear()
Dim ingprop As ingredient
Dim lbl As Label
Dim txtbox As TextBox
Dim setbutton As Button
For Each ingprop In ingredient.propertyList
lbl = New Label()
lbl.Text = "Property"
FlowLayoutPanel1.Controls.Add(lbl)
 
txtbox = New TextBox
txtbox.DataBindings.Add("Text", ingprop, "name", True,
DataSourceUpdateMode.OnPropertyChanged)
Me.FlowLayoutPanel1.Controls.Add(txtbox)
 
setbutton = btn_setval
FlowLayoutPanel1.Controls.Add(setbutton)
 
FlowLayoutPanel1.SetFlowBreak(setbutton, True)
 
Next
End Sub
************** End Code **************

Thanks for all your help.

-Blake
 
Last edited by a moderator:
Back
Top