Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

How to populate a listbox with items from another listbox ( items will be selected by double clicking)

I have two listboxes side by side and one that is on my left has bunch of items and one that is on my right is empty.
User will select items from left by double clicking on the item and the item should disappear from left and will be populated on right.
0
s_more
Asked:
s_more
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
How about something like:

    Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick

        If Not ListBox1.SelectedItem Is Nothing Then
            ListBox2.Items.Add(ListBox1.SelectedItem.ToString())
            ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
        End If

    End Sub
0
 
MageDribbleCommented:
in the OnDoubleClick method of the left listbox put the following:

lstRight.Items.Add(lstLeft.SelectedItem).ToString()
lstLeft.Items.RemoveAt(lstLeft.SelectedIndex)

lstRight is name of right list box
lstLeft is name of left list box

this is pseudo-code but it may work
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now