Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 1st, 2006, 08:55 AM
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default SelectedIndexChanged & Databinding problems

I'm really glad I found this forum b/c the book has helped me a lot. I've been stuck on this a couple of days - I'm very green and have only been using VB.NET for 3 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 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 **************
    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





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems with Select & Where statement sharon5469 ASP.NET 1.0 and 1.1 Basics 3 June 11th, 2007 07:09 PM
PHP & IE 6 Problems rdmapes PHP How-To 0 February 22nd, 2007 12:04 PM
Problems with namespaces & classes ayamas General .NET 1 October 12th, 2006 03:11 PM
problems with php4 & 5??? royp2p Beginning PHP 1 March 27th, 2005 10:05 AM
Problems with SelectedIndexChanged not firing Dalik .NET Web Services 2 December 9th, 2003 02:29 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.