Reputation: 31
if (Cursor.Position == closeButton.Location)
{
closeButton.BackColor = Color.FromArgb(255, 231, 76, 60);
}
This if statement doesn't work for some reason, any help?
I would like it to check if the Cursor position is in the Location set.
Upvotes: 1
Views: 73
Reputation: 39946
You need to check for ClientRectangle
property of your button. So this is the proper syntax to use:
if (closeButton.ClientRectangle.Contains(closeButton.PointToClient(Cursor.Position)))
{
closeButton.BackColor = Color.FromArgb(255, 231, 76, 60);
}
Upvotes: 3