For some reason MouseHover and MouseLeave functions behave really strange. All I need to do is, when the cursor is over the "button", I want to make the button visible and when the cursor leaves the button, I want to make it invisible. Whatever I try I couldn't make it work. It seems like Mouse events not working when the control object is invisible.
private void button1_MouseHover(object sender, EventArgs e)
{
button1.Visible = true;
}
private void button1_MouseLeave(object sender, EventArgs e)
{
button1.Visible = false;
}
Well... that's how it works. Continue handling the button's MouseLeave
event and handle MouseMove
for its parent (I assume the form):
private void Form_MouseMove(object sender, MouseEventArgs e) {
if (button1.Bounds.Contains(e.Location) && !button1.Visible) {
button1.Show();
}
}