Re: List box features by Steve
Steve
Fri Jul 18 12:26:36 CDT 2008
On Jul 15, 3:17 pm, kimiraikkonen <kimiraikkone...@gmail.com> wrote:
> On Jul 15, 11:08 pm, kimiraikkonen <kimiraikkone...@gmail.com> wrote:
>
>
>
> > On Jul 15, 9:37 pm, Steve <sithiu...@gmail.com> wrote:
>
> > > 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 arra=
y
> > > 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 =3D "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 =3D "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=FCzel
>
> 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=FCzel
Thank you very much for your help.
Steve