Listbox

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
4 posts Page 1 of 1
Contributors
User avatar
NeedHelp
Member
Member
Posts: 42
Joined: Fri Feb 19, 2010 3:57 pm

Listbox
NeedHelp
I want something like this:

If you select something in listbox1 it changes things in listbox2 like this:

You select -Game- in listbox1 this comes up in listbox2:
-1
-2
-3

and if you select -no game- in listbox1 this comes up in listbox2:
-4
-5
-8


any ideas?
User avatar
Agust1337
Coding God
Coding God
Posts: 2456
Joined: Fri Feb 19, 2010 8:18 pm

Re: Listbox
Agust1337
Well what you could do if I understand you right:
under Public class put these codes:
Code: Select all
Dim nr1 As String = "-1"
    Dim nr2 As String = "-2"
    Dim nr3 As String = "-3"
    Dim nr4 As String = "-4"
    Dim nr5 As String = "-5"
    Dim nr8 As String = "-8"
Then double click ListBox1 and put these codes:
(should be Listbox1_SelectedIndexChanged)
Code: Select all
 If ListBox1.Text = "Game" Then
            ListBox2.Items.Add(nr1 & vbNewLine)
            ListBox2.Items.Add(nr2 + vbNewLine)
            ListBox2.Items.Add(nr3 + vbNewLine)
            If ListBox2.Items.Contains(nr4) Then
                ListBox2.Items.Remove(nr4)
            End If
            If ListBox2.Items.Contains(nr5) Then
                ListBox2.Items.Remove(nr5)
            End If
            If ListBox2.Items.Contains(nr8) Then
                ListBox2.Items.Remove(nr8)
            End If
        Else
            If ListBox1.Text = "No game" Then
                If ListBox2.Items.Contains(nr1) Then
                    ListBox2.Items.Remove(nr1)
                End If
                If ListBox2.Items.Contains(nr2) Then
                    ListBox2.Items.Remove(nr2)
                End If
                If ListBox2.Items.Contains(nr3) Then
                    ListBox2.Items.Remove(nr3)
                End If
                ListBox2.Items.Add(nr4 & vbNewLine)
                ListBox2.Items.Add(nr5 + vbNewLine)
                ListBox2.Items.Add(nr8 + vbNewLine)
            End If
        End If
Top-notch casual Dating
User avatar
NeedHelp
Member
Member
Posts: 42
Joined: Fri Feb 19, 2010 3:57 pm

Re: Listbox
NeedHelp
Yes like that but when you click on it 'game' 2 times it duplicate... and so on with no game to
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: Listbox
mandai
Maybe you could call Listbox.Items.Clear on the listbox you aren't clicking on before you add the items?
4 posts Page 1 of 1
Return to “Tutorial Requests”