Results 1 to 3 of 3

Thread: How do I move the data bound contents of one listbox to another

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2003
    Posts
    2

    Unhappy How do I move the data bound contents of one listbox to another

    have two listboxes side by side. The listbox on the left is bound to a table, and shows Sql selected data from that table. I need to Add selected items from this listbox to the listbox on the right which is not bound to anything. The Listbox on the left has the following properties:

    DisplayMember= Text field giving a display name from the table
    ValueMember=UniqueID for item in the table

    When I use the following:

    RightSideListBox.Items.Add(LeftSideListBox.SelectedValue)

    all I get is the Valuemember appearing in the right hand listbox. What I need is the DisplayMember showing in the right hand listbox, and some way of also recording the Valuemember, so I can retrieve data from the same table later, based on the UniqueID it returns for the originating table.

    I tried using :

    RightSideListBox.Items.Add(LeftSideListBox.SelectedItem)

    but while that appears to add the datarow object to the right hand listbox, it displays 'System.Data.DataRowView' in the listbox control. Again, what I need is to see the same DisplayMember for the selected item in the left side listbox displayed in the right side listbox, and have some way of retrieving the ValueMember for later use.

    Any help is greatfully appreciated!

    Regards,

    James

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Re: How do I move the data bound contents of one listbox to another

    try this

    VB Code:
    1. RightSideListBox.Items.Add(LeftSideListBox.SelectedValue.ToString)

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2003
    Posts
    2
    I'm afraid that doesn't work - this still gives me the ValueMember of the item in the left side listbox, and doesn't display the DisplayMember in the right side box.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width