Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a code on Class1:

C#
public void r1_MouseHov(Object sender, MouseEventArgs e)
       {
                int velRad = System.Int32.Parse(f1.toolStripTextBox2.Text);
                Rectangle oblRad = new Rectangle(e.X, e.X, velRad, velRad);
     ControlPaint.DrawReversibleFrame(f1.pictureBox4.RectangleToScreen(oblRad), Color.Black, FrameStyle.Thick);
       }

and on class Form1:
pictureBox4.MouseHover += new MouseEventHandler(Class1.r1_MouseHov);        


And i get the error:

Cannot implicitly convert type 'System.Windows.Forms.MouseEventHandler' to 'System.EventHandler'

MouseHover is not in the MouseEventHendler? If I use EventArgs (System.EventArgs) i can`t use e.X and e.Y? How to fix this? How do you add events like that?

What am i trying to do is when mouse hovers, it shows the rectangle by the pointer.
Posted

1 solution

The PictureBox.MouseHover event is directly inherited from Control, and does not supply MouseEventArgs - it uses EventArgs only.

If you need to know where the mouse is in your PictureBox in the Hover event, then use:
C#
Point p = myPictureBox.PointToClient(Cursor.Position);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900