473,474 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2464
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.