Hi! Hope my title is understandable.

I have four comboxes all containing A,B,C,D. My problem is if I have chosen letter A on the first combobox, the last three won't have letter A anymore, then on the second combobox, if letter B is chosen, the last two will have C and D and so on. Thank you very much and God Bless. :)

Recommended Answers

All 8 Replies

Here is the Code:
Here i only have 4 combobox on my Form1

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.ComboBox1.Items.Add("A")
        Me.ComboBox1.Items.Add("B")
        Me.ComboBox1.Items.Add("C")
        Me.ComboBox1.Items.Add("D")

        Me.ComboBox2.Items.Add("A")
        Me.ComboBox2.Items.Add("B")
        Me.ComboBox2.Items.Add("C")
        Me.ComboBox2.Items.Add("D")

        Me.ComboBox3.Items.Add("A")
        Me.ComboBox3.Items.Add("B")
        Me.ComboBox3.Items.Add("C")
        Me.ComboBox3.Items.Add("D")

        Me.ComboBox4.Items.Add("A")
        Me.ComboBox4.Items.Add("B")
        Me.ComboBox4.Items.Add("C")
        Me.ComboBox4.Items.Add("D")

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Me.ComboBox2.Items.Remove(Me.ComboBox1.SelectedItem.ToString())
        Me.ComboBox3.Items.Remove(Me.ComboBox1.SelectedItem.ToString())
        Me.ComboBox4.Items.Remove(Me.ComboBox1.SelectedItem.ToString())
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        Me.ComboBox3.Items.Remove(Me.ComboBox2.SelectedItem.ToString())
        Me.ComboBox4.Items.Remove(Me.ComboBox2.SelectedItem.ToString())

    End Sub

    Private Sub ComboBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox3.SelectedIndexChanged
        Me.ComboBox4.Items.Remove(Me.ComboBox3.SelectedItem.ToString())
    End Sub

    Private Sub ComboBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox4.SelectedIndexChanged

    End Sub
End Class

Wooh! It worked flawlessly! Thanks. It is kinda long but understandable. Thank you again. God Bless, you :)

your wellcome..

please mark the thread solved :)

Okay. :D

Excuse me, but I just noticed that I have problem regarding the program. On the second to last comboboxes, whenever I chose a letter and I want to change what I pick, the first letter I chose doesn't show anymore, so in the last combobox, I don't have any value to choose anymore. Thanks! God Bless. :)

ofcourse it would be like that .. once u select a value from second to last that value will be removed from last combo box..

what u can do is put a RESET button which will load the all the value again.

so if I chose A for combobox2 and changed my selected value of combobox2 to C, the ntex comboboxes won't have the letter A anymore., I have to produce a button that will reset each comboboxes? Is there anyway that I can reset them without using a button? Because it's kinda awkward to use button just to reset a certain combobox if the user made a mistake choosing the letter Thanks again! God Bless. :)

u can prove CTRL + Z option..

if a user make a mistake then tell him to press CTRL + Z .. and write the code for resetting the combobox when user presses ctrl + Z

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.