Search code examples
c#pictureboxmousehovereventhandler

On c# the mousehover on a picturebox appear to do nothing.Do i need some kind of eventhandler?


I am trying to create a MouseHover event for a pictureBox, but I have had no luck so far:

private void pictureBox1_MouseHover(object sender, EventArgs e)
{
  pictureBox1.Image = ArgyroCinema.Properties.Resources.ktz00h07;
  label1.Text = "hover";
}

private void pictureBox1_Click(object sender, EventArgs e)
{
  pictureBox1.Image = ArgyroCinema.Properties.Resources.ktz00h07;
}

private void pictureBox1_MouseLeave(object sender, EventArgs e)
{
  pictureBox1.Image = ArgyroCinema.Properties.Resources.ktz00h07;
}

What is going on here? MouseClick works correctly, maybe I have to add something on Form1.Designer.cs ?


Solution

  • ok i had to add this line on the constructor: this.pictureBox1.MouseHover += new System.EventHandler(this.pictureBox1_MouseHover); although i will use mouseenter, its faster