deryk_2784

deryk_2784

  • NA
  • 27
  • 0

help! big problem with mouseenter and mouseleave

Aug 26 2004 2:42 PM
hi. i recently set up a picturebox to act as a button. it already has its on_click method which works perfectly. however, for added spice, i decided to added a mouseover glow effect to it. for this to work, i placed a second, glowing version of the bitmap over the picturebox and set it to Hide(). i set up a mouseenter method and a mouseleave method as follows: pictureBox1.MouseEnter += new System.EventHandler(this.OnMouseEnterEvent); pictureBox1.MouseLeave += new System.EventHandler(this.OnMouseLeaveEvent); their respective methods are as follows: private void OnMouseEnterEvent(object sender, System.EventArgs e) { this.pictureBox2.Show(); } private void OnMouseLeaveEvent(object sender, System.EventArgs e) { this.pictureBox2.Hide(); } as you can see, it's basically setup to Show the second picture when the mouse is over the picturebox, and to hide it when the mouse leaves the area. however, what happens is that upon hovering my mouse over the button, the two events happen in rapid succession, so no effect is seen. i tried adding messageboxes to each method to see which occurs first, and it appears that the mouseleave event actually happens first, followed by the mouseenter (the mouseleave method displays its messagebox first). any tips on how to fix this problem? thanks. :)

Answers (3)