Hi i've been searching everywhere to try to get this setup. I am running Visual Basic 2008

I have 1 Combo Box that Has 3 Entries, Kyocera>Konica>Toshiba

I have a 2nd Combo Box that has entries for each of those manufactors...Kyocera has 3035,4035,5035....the konica has c250,c352,c452......the Toshiba has c3520, 4520

I want it so when i click on Kyocera the 2nd combo box only reads 3035,4035,5035 and when i click konica it only reads c250,c352,c452 etc etc

Thank you for your help

Member Avatar

Unhnd_Exception

Heres a way to do the above.

Public Class Form1

    Private Kyocera() As String = {"3035", "4035", "5035"}
    Private Konica() As String = {"c250", "c352", "c452"}
    Private Toshiba() As String = {"c3520", "4520"}

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ComboBox1.Items.Add("Kyocera")
        ComboBox1.Items.Add("Konica")
        ComboBox1.Items.Add("Toshiba")
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.SelectedIndex = -1 Then Exit Sub

        ComboBox2.Items.Clear()

        'The string array based on selection
        Dim StateObject As String() = Nothing

        Select Case CStr(ComboBox1.SelectedItem)
            Case "Kyocera"
                StateObject = Kyocera
            Case "Konica"
                StateObject = Konica
            Case "Toshiba"
                StateObject = Toshiba
        End Select

        'Fill combobox 2 with all the values in the selected array.
        If StateObject IsNot Nothing Then
            ComboBox2.Items.AddRange(StateObject)
            ComboBox2.SelectedIndex = 0
        End If
    End Sub

End Class

Another Version

Public Class Form1

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ComboBox1.Items.Add("Kyocera")
        ComboBox1.Items.Add("Konica")
        ComboBox1.Items.Add("Toshiba")
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        If ComboBox1.SelectedIndex = -1 Then Exit Sub

        ComboBox2.Items.Clear()

        Select Case CStr(ComboBox1.SelectedItem)
            Case "Kyocera"
                ComboBox2.Items.AddRange(New String() {"3035", "4035", "5035"})
            Case "Konica"
                ComboBox2.Items.AddRange(New String() {"c250", "c352", "c452"})
            Case "Toshiba"
                ComboBox2.Items.AddRange(New String() {"c3520", "4520"})
        End Select

        If ComboBox2.Items.Count > 0 Then ComboBox2.SelectedIndex = 0

    End Sub

End Class

If this helps you mark the thread as solved, otherwise say why it didn't help you.

Your the best thank you very much...do you mind looking at my other threads please...thanks again