kris594
kris594

Reputation: 257

Button mouse over ForeColour change

To create a mouse over button I use this code

    private void btnCreateAccount_MouseHover(object sender, EventArgs e)
    {
        btnCreateAccount.ForeColor = Color.Gold;
    }

    private void btnCreateAccount_MouseLeave(object sender, EventArgs e)
    {
        btnCreateAccount.ForeColor = Color.Black;
    }

The mouse over button works however when I hover over the button there is a good at least 1 second delay. I would think that it should change colour as soon as the mouse is placed over the button and not with a (in my opinion) too long delay.

Is there any way of fixing that code by like refreshing the button or something along those lines? or perhaps someone has a code that works perfectly?

Upvotes: 0

Views: 42

Answers (1)

ChrisF
ChrisF

Reputation: 137188

You are handling the Mouse Hover event. This will require the cursor to be still for a short while in order to fire.

The pause required for this event to be raised is specified in milliseconds by the MouseHoverTime property.

This is read only.

Normally if you want the colour to change immediately you should handle the Mouse Enter event:

private void btnCreateAccount_MouseEnter(object sender, EventArgs e)
{
    btnCreateAccount.ForeColor = Color.Gold;
}

Upvotes: 2

Related Questions