Selected Item In Combo Box Will Not Appear In Another Combo Box

theazza

Member
Joined
May 20, 2011
Messages
23
Programming Experience
1-3
how do i program by saying if a certain item is selected in a combo box then that item will not appear in a second combo box. i have this code for now but it does not work

VB.NET:
 j = 0
        Do While j < cmbSession.Items.Count
            If (j <> lesson) Then
            cmbChange.Items.Add(cmbSession.Items)
        Next
            End If
            j += 1
        Loop
 
Can you post the entire code? I am very confused about the position of that Next, what event this code is in, and a few other things. The entire code block would be very useful, and also please describe what is happening currently.
 
it quite simply wont work
please ask further if u don't understand from the code


VB.NET:
 Private Sub cmbSession_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbSession.SelectedIndexChanged

        Dim session As String = cmbSession.SelectedIndex
        Dim j As Integer
        Dim lesson As Integer = cmbSession.SelectedIndex
        Dim Classes As String = cmbSession.Text

        lstNames.Items.Clear()
        lstupdate.Items.Clear()
        cmbChange.Items.Clear()

        For Each item In cmbSession.Items()
            cmbChange.Items.Add(item)
        Next


        j = 0
        Do While j < cmbSession.Items.Count
            If (j <> lesson) Then
                cmbChange.Items.Add(cmbSession.Items)

            End If
            j += 1
        Loop


                If session = 0 Then
                    Do While allocation1.Peek <> -1
                        lstNames.Items.Add(allocation1.ReadLine())
                    Loop
                    allocation1.Close()

                ElseIf session = 1 Then
                    Do While allocation2.Peek <> -1
                        lstNames.Items.Add(allocation2.ReadLine())
                    Loop
                    allocation2.Close()

                ElseIf session = 2 Then
                    Do While allocation3.Peek <> -1
                        lstNames.Items.Add(allocation3.ReadLine())
                    Loop
                    allocation3.Close()

                ElseIf session = 3 Then
                    Do While allocation4.Peek <> -1

                        lstNames.Items.Add(allocation4.ReadLine())
                    Loop
                    allocation4.Close()
                End If
 
Back
Top