473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Listboxes

Dag
Hello there! I have a problem here. For many of you it
would not be a problem at all, but I am new in
programming...so here is the question:

I have a form with two listboxes in it....Listbox1 and
Listbox2. Listbox1 contains some names and listbox2
contains nothing. if I doubleclick Listbox1 all names in
that listbox will be transferred to listbox2 (Listbox1
will now be empty and Listbox2 filled)...the next thing
is...Solution 1: if I doubleclick listbox2 all the names
will be deleted...or solution 2: all the names will be
transferred back again....

Thanx in advance
DG, Norway
Nov 20 '05 #1
3 2455
Hi Dag, this might be what you are after or point you in the right
direction. Just paste it into your application with the two listboxes
(ListBox1 and ListBox2) on the form.
Happy to help
Colin
Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListBox1.DoubleClick
ListBox2.Items.AddRange(ListBox1.Items())
ListBox1.Items.Clear()
End Sub
Private Sub ListBox2_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListBox2.DoubleClick
Dim answer As MsgBoxResult = MsgBox("Answer 'Yes' to clear listbox 2
or 'No' to transfer content from listbox 2 to listbox 1",
MsgBoxStyle.YesNoCancel, "Transfer or Clear")
If answer = MsgBoxResult.Yes Then
ListBox2.Items.Clear()
Else
ListBox1.Items.AddRange(ListBox2.Items())
ListBox2.Items.Clear()
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
ListBox2.Items.Clear()
ListBox1.Items.Clear()
ListBox1.Items.Add("John")
ListBox1.Items.Add("Ringo")
ListBox1.Items.Add("Paul")
ListBox1.Items.Add("George")
End Sub


"Dag" <mr**********@hotmail.com> wrote in message
news:00****************************@phx.gbl...
Hello there! I have a problem here. For many of you it
would not be a problem at all, but I am new in
programming...so here is the question:

I have a form with two listboxes in it....Listbox1 and
Listbox2. Listbox1 contains some names and listbox2
contains nothing. if I doubleclick Listbox1 all names in
that listbox will be transferred to listbox2 (Listbox1
will now be empty and Listbox2 filled)...the next thing
is...Solution 1: if I doubleclick listbox2 all the names
will be deleted...or solution 2: all the names will be
transferred back again....

Thanx in advance
DG, Norway


Nov 20 '05 #2
Hi DG

Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListBox1.DoubleClick
Dim a As Object
For Each a In ListBox1.Items
ListBox2.Items.Add(a)
Next
ListBox1.Items.Clear()
End Sub

Private Sub ListBox2_DoubleClick(ByVal sender As Object, ByVal e As
System.EventArgs) Handles ListBox2.DoubleClick
' Solution 1
ListBox2.Items.Clear()
'Solution2
Dim a As Object
For Each a In ListBox2.Items
ListBox1.Items.Add(a)
Next
ListBox2.Items.Clear()
End Sub
Best regards

Jan
"Dag" <mr**********@hotmail.com> skrev i en meddelelse
news:00****************************@phx.gbl...
Hello there! I have a problem here. For many of you it
would not be a problem at all, but I am new in
programming...so here is the question:

I have a form with two listboxes in it....Listbox1 and
Listbox2. Listbox1 contains some names and listbox2
contains nothing. if I doubleclick Listbox1 all names in
that listbox will be transferred to listbox2 (Listbox1
will now be empty and Listbox2 filled)...the next thing
is...Solution 1: if I doubleclick listbox2 all the names
will be deleted...or solution 2: all the names will be
transferred back again....

Thanx in advance
DG, Norway

Nov 20 '05 #3
* "Dag" <mr**********@hotmail.com> scripsit:
I have a form with two listboxes in it....Listbox1 and
Listbox2. Listbox1 contains some names and listbox2
contains nothing. if I doubleclick Listbox1 all names in
that listbox will be transferred to listbox2 (Listbox1
will now be empty and Listbox2 filled)...the next thing
is...Solution 1: if I doubleclick listbox2 all the names
will be deleted...or solution 2: all the names will be
transferred back again....


\\\
Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
Me.ListBox2.Items.AddRange(Me.ListBox1.Items)
Me.ListBox1.Items.Clear()
End Sub

Private Sub ListBox2_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox2.DoubleClick
Me.ListBox1.Items.AddRange(Me.ListBox2.Items)
Me.ListBox2.Items.Clear()
End Sub
///

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: bill yeager | last post by:
I have several template columns inside of a datagrid. Inside of these template columns are databound listboxes: <asp:TemplateColumn HeaderText="Crew Chiefs"> <ItemTemplate> <asp:listbox...
0
by: Terry D | last post by:
I'm having an issue with an ASP.NET page (VS.NET 2003, VB.NET, Oracle back end). The page uses the standard VS.NET grid to display the records from a particular table. The user can edit certain...
1
by: Ryan Ternier | last post by:
I have two listboxes, and allow users to move items between them via the following function: function SwitchList(fbox, tbox){ var arrFbox = new Array(); var arrTbox = new Array(); var...
0
by: Luis Esteban Valencia | last post by:
have a problem and I'm not sure how to handle/fix it. I have three listboxes on my page. The first listbox has a list of software products. When you select an item in the Products listbox, then...
2
by: salad | last post by:
This is a tip on how to speed up listboxes DRAMATICALLY. Persons that would benefit are those that are constantly updating the rowsource of a listbox/combobox in order to filter and sort the data...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.