473,406 Members | 2,387 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,406 software developers and data experts.

List box features

Hello all:

I am working on a project that has two list boxes side-by-side on a
form. What I want to happen is when a user clicks on an item in the
list box on the left, the list box on the right displays information
related to only that item. I would like to be able to connect to a
SQL database to retrieve the items and possibly store them in an array
and then loop through the array to populate the list box.

ListBox1 ListBox2
--------------- ----------------
Sports ----Basketball
Soccer
Football
Cars -------Ford
Chevrolet
Dodge

Can someone help me on this or can someone point in the direction to
at least get things moving?

Thanks for the info.

Steve
Jul 15 '08 #1
6 1097
On Jul 15, 2:46 pm, Reg Verrin <r...@yingtongtiddleipoyaknow.com>
wrote:
Set up an event handler for Listbox1 so that you know the item that's
been clicked.

Private Sub Listbox1_MouseClick (etc)
Dim ItemNumber As Integer

ItemNumber = Listbox1.SelectedIndex

'ItemNumber now holds the index of the item that was clicked
(starts at zero)

End Sub

You can then provide details for that item in Listbox2.
Thank you very much. I will try this out.
Jul 15 '08 #2
On Jul 15, 9:37 pm, Steve <sithiu...@gmail.comwrote:
Hello all:

I am working on a project that has two list boxes side-by-side on a
form. What I want to happen is when a user clicks on an item in the
list box on the left, the list box on the right displays information
related to only that item. I would like to be able to connect to a
SQL database to retrieve the items and possibly store them in an array
and then loop through the array to populate the list box.

ListBox1 ListBox2
--------------- ----------------
Sports ----Basketball
Soccer
Football
Cars -------Ford
Chevrolet
Dodge

Can someone help me on this or can someone point in the direction to
at least get things moving?

Thanks for the info.

Steve
Hi,

If i understood right, here may be the one that demonstrates what you
meant:

Just add 2 listbox's on your form named "ListBox1" which resides on
the right and "ListBox2" which resides on the left of your form:

' ----Code Begins----

'Full code will look like this:

Public Class Form1

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListBox1.SelectedIndexChanged
If ListBox1.SelectedItem = "Sports" Then
'First clear listbox2
ListBox2.Items.Clear()
'Then display add (display) related
'items in listbox2
ListBox2.Items.Add("Basketball")
ListBox2.Items.Add("Soccer")
ListBox2.Items.Add("Football")
ElseIf ListBox1.SelectedItem = "Cars" Then
'First clear listbox2
ListBox2.Items.Clear()
'Then display add (display) related
'items in listbox2
ListBox2.Items.Add("Ford")
ListBox2.Items.Add("Chevrolet")
ListBox2.Items.Add("Dodge")
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Here items are added manually, as you can retrieve them
'using your proper SQL connection methods
ListBox1.Items.Add("Sports")
ListBox1.Items.Add("Cars")
End Sub
End Class

' ---Code Ends------
Hope this helps,

Onur Güzel
Jul 15 '08 #3
On Jul 15, 11:08 pm, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Jul 15, 9:37 pm, Steve <sithiu...@gmail.comwrote:
Hello all:
I am working on a project that has two list boxes side-by-side on a
form. What I want to happen is when a user clicks on an item in the
list box on the left, the list box on the right displays information
related to only that item. I would like to be able to connect to a
SQL database to retrieve the items and possibly store them in an array
and then loop through the array to populate the list box.
ListBox1 ListBox2
--------------- ----------------
Sports ----Basketball
Soccer
Football
Cars -------Ford
Chevrolet
Dodge
Can someone help me on this or can someone point in the direction to
at least get things moving?
Thanks for the info.
Steve

Hi,

If i understood right, here may be the one that demonstrates what you
meant:

Just add 2 listbox's on your form named "ListBox1" which resides on
the right and "ListBox2" which resides on the left of your form:

' ----Code Begins----

'Full code will look like this:

Public Class Form1

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListBox1.SelectedIndexChanged
If ListBox1.SelectedItem = "Sports" Then
'First clear listbox2
ListBox2.Items.Clear()
'Then display add (display) related
'items in listbox2
ListBox2.Items.Add("Basketball")
ListBox2.Items.Add("Soccer")
ListBox2.Items.Add("Football")
ElseIf ListBox1.SelectedItem = "Cars" Then
'First clear listbox2
ListBox2.Items.Clear()
'Then display add (display) related
'items in listbox2
ListBox2.Items.Add("Ford")
ListBox2.Items.Add("Chevrolet")
ListBox2.Items.Add("Dodge")
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Here items are added manually, as you can retrieve them
'using your proper SQL connection methods
ListBox1.Items.Add("Sports")
ListBox1.Items.Add("Cars")
End Sub
End Class

' ---Code Ends------

Hope this helps,

Onur Güzel
Sorry i want to correct positions of listboxes on your form,
"ListBox1" should be placed on the LEFT of your form and "ListBox2"
should be placed on the RIGHT of your form, the rest code is the same
as my previous post.

Hope this helps,

Onur Güzel
Jul 15 '08 #4
On Jul 15, 3:17 pm, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Jul 15, 11:08 pm, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Jul 15, 9:37 pm, Steve <sithiu...@gmail.comwrote:
Hello all:
I am working on a project that has twolistboxes side-by-side on a
form. What I want to happen is when a user clicks on an item in the
>listboxon the left, thelistboxon the right displays information
related to only that item. I would like to be able to connect to a
SQL database to retrieve the items and possibly store them in an array
and then loop through the array to populate thelistbox.
ListBox1 ListBox2
--------------- ----------------
Sports ----Basketball
Soccer
Football
Cars -------Ford
Chevrolet
Dodge
Can someone help me on this or can someone point in the direction to
at least get things moving?
Thanks for the info.
Steve
Hi,
If i understood right, here may be the one that demonstrates what you
meant:
Just add 2 listbox's on your form named "ListBox1" which resides on
the right and "ListBox2" which resides on the left of your form:
' ----Code Begins----
'Full code will look like this:
Public Class Form1
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListBox1.SelectedIndexChanged
If ListBox1.SelectedItem = "Sports" Then
'First clear listbox2
ListBox2.Items.Clear()
'Then display add (display) related
'items in listbox2
ListBox2.Items.Add("Basketball")
ListBox2.Items.Add("Soccer")
ListBox2.Items.Add("Football")
ElseIf ListBox1.SelectedItem = "Cars" Then
'First clear listbox2
ListBox2.Items.Clear()
'Then display add (display) related
'items in listbox2
ListBox2.Items.Add("Ford")
ListBox2.Items.Add("Chevrolet")
ListBox2.Items.Add("Dodge")
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Here items are added manually, as you can retrieve them
'using your proper SQL connection methods
ListBox1.Items.Add("Sports")
ListBox1.Items.Add("Cars")
End Sub
End Class
' ---Code Ends------
Hope this helps,
Onur Güzel

Sorry i want to correct positions of listboxes on your form,
"ListBox1" should be placed on the LEFT of your form and "ListBox2"
should be placed on the RIGHT of your form, the rest code is the same
as my previous post.

Hope this helps,

Onur Güzel
Thank you very much for your help.

Steve
Jul 18 '08 #5
On Jul 15, 3:08 pm, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Jul 15, 9:37 pm, Steve <sithiu...@gmail.comwrote:
Hello all:
I am working on a project that has two list boxes side-by-side on a
form. What I want to happen is when a user clicks on an item in the
list box on the left, the list box on the right displays information
related to only that item. I would like to be able to connect to a
SQL database to retrieve the items and possibly store them in an array
and then loop through the array to populate the list box.
ListBox1 ListBox2
--------------- ----------------
Sports ----Basketball
Soccer
Football
Cars -------Ford
Chevrolet
Dodge
Can someone help me on this or can someone point in the direction to
at least get things moving?
Thanks for the info.
Steve

Hi,

If i understood right, here may be the one that demonstrates what you
meant:

Just add 2 listbox's on your form named "ListBox1" which resides on
the right and "ListBox2" which resides on the left of your form:

' ----Code Begins----

'Full code will look like this:

Public Class Form1

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListBox1.SelectedIndexChanged
If ListBox1.SelectedItem = "Sports" Then
'First clear listbox2
ListBox2.Items.Clear()
'Then display add (display) related
'items in listbox2
ListBox2.Items.Add("Basketball")
ListBox2.Items.Add("Soccer")
ListBox2.Items.Add("Football")
ElseIf ListBox1.SelectedItem = "Cars" Then
'First clear listbox2
ListBox2.Items.Clear()
'Then display add (display) related
'items in listbox2
ListBox2.Items.Add("Ford")
ListBox2.Items.Add("Chevrolet")
ListBox2.Items.Add("Dodge")
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Here items are added manually, as you can retrieve them
'using your proper SQL connection methods
ListBox1.Items.Add("Sports")
ListBox1.Items.Add("Cars")
End Sub
End Class

' ---Code Ends------

Hope this helps,

Onur Güzel
Thanks for the help. Looking at your example started to generate
ideas for what I wanted to do. I was able to get the listbox working
the way I wanted it to.
Jul 21 '08 #6
On Jul 21, 6:26 pm, Steve <sithiu...@gmail.comwrote:
On Jul 15, 3:08 pm, kimiraikkonen <kimiraikkone...@gmail.comwrote:
On Jul 15, 9:37 pm, Steve <sithiu...@gmail.comwrote:
Hello all:
I am working on a project that has two list boxes side-by-side on a
form. What I want to happen is when a user clicks on an item in the
list box on the left, the list box on the right displays information
related to only that item. I would like to be able to connect to a
SQL database to retrieve the items and possibly store them in an array
and then loop through the array to populate the list box.
ListBox1 ListBox2
--------------- ----------------
Sports ----Basketball
Soccer
Football
Cars -------Ford
Chevrolet
Dodge
Can someone help me on this or can someone point in the direction to
at least get things moving?
Thanks for the info.
Steve
Hi,
If i understood right, here may be the one that demonstrates what you
meant:
Just add 2 listbox's on your form named "ListBox1" which resides on
the right and "ListBox2" which resides on the left of your form:
' ----Code Begins----
'Full code will look like this:
Public Class Form1
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
ListBox1.SelectedIndexChanged
If ListBox1.SelectedItem = "Sports" Then
'First clear listbox2
ListBox2.Items.Clear()
'Then display add (display) related
'items in listbox2
ListBox2.Items.Add("Basketball")
ListBox2.Items.Add("Soccer")
ListBox2.Items.Add("Football")
ElseIf ListBox1.SelectedItem = "Cars" Then
'First clear listbox2
ListBox2.Items.Clear()
'Then display add (display) related
'items in listbox2
ListBox2.Items.Add("Ford")
ListBox2.Items.Add("Chevrolet")
ListBox2.Items.Add("Dodge")
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Here items are added manually, as you can retrieve them
'using your proper SQL connection methods
ListBox1.Items.Add("Sports")
ListBox1.Items.Add("Cars")
End Sub
End Class
' ---Code Ends------
Hope this helps,
Onur Güzel

Thanks for the help. Looking at your example started to generate
ideas for what I wanted to do. I was able to get the listbox working
the way I wanted it to.
No problem, i'm glad that it worked,

Thanks,

Onur Güzel
Jul 21 '08 #7

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

Similar topics

24
by: Mahesh Padmanabhan | last post by:
Hi, When list comprehension was added to the language, I had a lot of trouble understanding it but now that I am familiar with it, I am not sure how I programmed in Python without it. Now I...
24
by: Mandus | last post by:
Hi there, inspired by a recent thread where the end of reduce/map/lambda in Python was discussed, I looked over some of my maps, and tried to convert them to list-comprehensions. This one I...
30
by: Steven Bethard | last post by:
George Sakkis wrote: > "Steven Bethard" <steven.bethard@gmail.com> wrote: >> Dict comprehensions were recently rejected: >> http://www.python.org/peps/pep-0274.html >> The reason, of course,...
7
by: Zorro | last post by:
For almost a decade now some desirable features have appeared in circulations as C++ wish list. Consider the following features. Invariants and Contracts. Extending enumerations. Namespaces...
17
by: Aladdin | last post by:
Hi, all! I'm looking for a list of features that are supported in C but not supported in C++. I also need the complete list of language alterations from K&R C to C89 then to C99. Would anyone...
2
by: Peter | last post by:
Is there a way to get the email address list from Global Address Book using Active Directory or some other method without Outlook or any other COM program? Outlook displays the dialog box when you...
35
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is...
0
by: shapper | last post by:
Hello, I have an enum as follows: Public Enum Feature Title Content Date Search End
2
by: Giovanni R. | last post by:
I'm going to use PHP6. Does there exist a list of OOP features that will be introduced in PHP6 and a list of OOP features that it still won't have? Thanks, Giovanni -- Advanced PHP...
4
by: shapper | last post by:
Hello, I am getting various records from a database: Dim ds As DataSet = db.ExecuteDataSet(dbc) Each record has 3 fields: Id, Name and Text. I have a class named MyClass with 3 properties...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
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...

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.