moving data from one ListBox to Another ListBox

DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: moving data from one ListBox to Another ListBox

  1. #1
    Join Date
    Jul 2008

    moving data from one ListBox to Another ListBox

    I am using the code posted by Kerry which adds all the Items from ListBox2 to ListBox1. Is there any way to add one selected item at a time from ListBox2 to ListBox1 and remove the items added to ListBox1 from ListBox2??

    Below is the code used by me:

    Me.ListBox1.DisplayMember = Me.ListBox2.DisplayMember
    Me.ListBox1.ValueMember = Me.ListBox2.ValueMember

    For Each item In Me.ListBox2.Items

  2. #2
    Join Date
    Apr 2007
    Sterling Heights, Michigan
    'move all items
    Dim i As Long
       For i = 0 To List1.ListCount - 1
           List2.AddItem List1.List(i)
    'move selected items
    Dim i As Long
    For i = List2.ListCount - 1 To 0 Step -1 ' counts list entries
        If List2.Selected(i) = True Then ' if selected then
            List1.AddItem List2.List(i) ' add to other list
            List2.RemoveItem i ' optional remove
        End If
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

Similar Threads

  1. How Vietnam Can Still Be Won
    By Steven Hughes in forum Architecture and Design
    Replies: 0
    Last Post: 02-19-2008, 07:07 AM
  2. Replies: 6
    Last Post: 01-22-2008, 09:19 AM
  3. Moving data between sources
    By Russell Nash in forum .NET
    Replies: 0
    Last Post: 01-13-2006, 08:20 AM
  4. Data Junction Announces XML Junction 7.51
    By Tim Frost in forum xml.announcements
    Replies: 0
    Last Post: 04-02-2001, 10:53 AM
  5. Complex Data Consumer Data Aware Classes
    By Desmond Cassidy in forum authorevents.kurata
    Replies: 3
    Last Post: 04-19-2000, 03:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center