views:

20

answers:

1

I really need help working with cases, I'm only learning it so far, but just can't get a drop down menu to work that would change the background of a Textbox.

Private Sub cbColours_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbColours.SelectedIndexChanged
    Select Case colours

        Case Is = "Red"
            txtSpace.BackColor = Color.Red

        Case Is = "Blue"
            txtSpace.BackColor = Color.Blue

        Case Is = "Green"
            txtSpace.BackColor = Color.Green

    End Select
End Sub

It isn't doing anything at all...

In the dropdown menu, it has

Red, Blue and Green one per line

When the value (e.g. Green) is clicked, it will then change the Textbox to the colour selected.

Many help appreciated :)

A: 

Not sure where you're getting the colours value, here's the simple one:

Private Sub cbColours_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cbColours.SelectedIndexChanged 
    Select Case Sender.Text     
        Case Is = "Red" 
            txtSpace.BackColor = Color.Red 

        Case Is = "Blue" 
            txtSpace.BackColor = Color.Blue 

        Case Is = "Green" 
            txtSpace.BackColor = Color.Green 

    End Select 
End Sub 
Jeff O