change label color

marlon_1_2

Member
Joined
Aug 20, 2008
Messages
6
Programming Experience
Beginner
Hi,

Can anyone help me: I need to create a simple label and when the user clicks the label, the label changes color...sounds easy BUT...if the user moves the mouse cursor away from the label and then clicks the label a second time, then label returns to its original color.

I am trying to create a loop to loop through two array indices, but it just doesnt seem to work.

Thanks guys

Marlon
 
I see no need for a loop based on what you have said.
marlon_1_2 said:
I need to create a simple label and when the user clicks the label, the label changes color...sounds easy BUT...if the user moves the mouse cursor away from the label and then clicks the label a second time, then label returns to its original color.
VB.NET:
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
        If Label1.BackColor = Color.White Then
            Label1.BackColor = Color.Red
        Else
            Label1.BackColor = Color.White
        End If
End Sub
 
Thanks

Hack,

I forgot to thank you. The code does exactly what I need it to do, and you have given me other ideas too.

Sorry in the delay, but thanks very much


Marlon
 
Back
Top