Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button control acting odd after grammatically resetting.

Status
Not open for further replies.

Shift838

IS-IT--Management
Jan 27, 2003
987
0
0
US
I have a form with some buttons on it and when the button is clicked it changes the background color. Pretty simple and that part works fine when the form is first ran.

The issue I am having is if I hit another button on the form that is a 'RESET' button, that resets the background colors of the buttons back to what they originally were and when you try to click on the buttons again it now takes 2 clicks to get the button to activate.

Sample of my code:

Code:
Private Sub LB1R1_Click(sender As Object, e As EventArgs) Handles LB1R1.Click
        If LB1R1.BackColor = Color.Cyan Then
            LB1R1.BackColor = Color.Black
        Else
            LB1R1.BackColor = Color.Cyan
        End If
        If LB1R1.BackColor = Color.Black Then
            lb1r1e = 1
        Else
            lb1r1e = 0
        End If
End Sub

Private Sub cmdreset_Click(sender As Object, e As EventArgs) Handles cmdreset.Click
        LB1R1.BackColor = Color.Aqua
End Sub
 
Can you distinguish [tt]Color.Cyan[/tt] and [tt]Color.Aqua[/tt] 'by eye'?
Your cmdreset sets LB1R1 to Aqua, you click on LB1R1 to set it to Cyan.

In my opinion, all works well and the way it should, you just cannot see the difference. :)

Try this:
Code:
    Private Sub LB1R1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles LB1R1.Click
        LB1R1.BackColor = Color.Cyan
    End Sub

    Private Sub cmdreset_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cmdreset.Click
        cmdreset.BackColor = Color.Aqua
    End Sub

Click on both buttons, can you see the difference?

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
that's what I get for trying to write this code when I was on ambien!

It should have been Cyan all the way through.

Good catch Andrzejek, i usually use Cyan, don't know why i typed Aqua. Must have been the ambien.. works like it should with the change to all the correct colors!

Thanks again.

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top