1

I have a little problem: I want to make some app in VB and I make two CheckedListBoxs and I have some idea: if I chose something in CheckedListBox1 I want to show some date inside CheckedListBox2.

I have a problem with declaration - I make something like this:

Dim model3 = {"A", "B", "C"}

But I have only one information inside CheckedListBox2: 'String[]'

If CheckedListBox1.CheckedItems.Count <> 0 Then

    If CheckedListBox1.SelectedItem.ToString = "GWW" Then
        Marka.Items.Add(model1)

    ElseIf CheckedListBox1.SelectedItem.ToString = "AWW" Then
        Marka.Items.Add(model2)
    ElseIf CheckedListBox1.SelectedItem.ToString = "ZWW" Then
        Marka.Items.Add(model3)
    End If
Else
    Marka.Items.Clear()
End If

Could you give me some prompt? I do not have too much experience so if I could asked as simple as possible :)

Andrew Morton
  • 24,203
  • 9
  • 60
  • 84
gajus21
  • 11
  • 3

1 Answers1

1

That's because you're only adding one item - the array itself - and the CheckedListBox will call its ToString method to get text that it can display, which is what you see. If what you actually want to do is add all the elements in the array into the CheckedListBox then you need to call AddRange rather than Add.

jmcilhinney
  • 50,448
  • 5
  • 26
  • 46
  • Thank You it's work. And what if I want make add/remove from CheckListBox2? Right now I only clear whole list (sometimes and sometimes not). – gajus21 Nov 09 '18 at 09:17
  • The issue you had has been resolved. Accept the answer and be done with this thread. If you have a new question, post it as a new question with all the information relevant to the new question and none that is specific to this old question. – jmcilhinney Nov 09 '18 at 09:40
  • OK I'm new one next time I will do it like You said. – gajus21 Nov 09 '18 at 10:38