MouseHover Events

I created pictureboxes for different images and i need to mousehover to each image.

and i implemented some codes but it is not working.

Please guide.
thank u.
private Point mouseLocation = new Point(0, 0);
        public Form1()
        {
            InitializeComponent();
            string ImagePath = Application.StartupPath + @"\\Model Products v3\";

            string[] Images = new string[] { ImagePath + "FingerprintScanner1Button.jpg", ImagePath + "FingerprintScanner2Button.jpg", ImagePath + "FingerprintScanner3Button.jpg" };

        
            int X = 0;
            foreach (string img in Images)
            {
                PictureBox PB = new PictureBox();
                PB.Width = PB.Height = 43;
                PB.Location = new Point(44 * X, 24);
                PB.Image = Image.FromFile(img);
                PB.MouseDown += new MouseEventHandler(PB_MouseDown);
             //   PB.MouseHover += new MouseEventHandler(PB_MouseHover);
                this.Controls.Add(PB);
                X++;
            }
        }

        int x;
        int y;

        void PB_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                x = e.X;
                y = e.Y;


                PictureBox pictureBox = new PictureBox();
                pictureBox.Image = ((PictureBox)sender).Image;
                pictureBox.Top = ((PictureBox)sender).Top;
                pictureBox.Width = ((PictureBox)sender).Width;
                pictureBox.Height = ((PictureBox)sender).Height;
                pictureBox.Left = ((PictureBox)sender).Left;
                pictureBox.MouseMove += new MouseEventHandler(PictureBox_MouseMove);
                pictureBox.MouseDown += new MouseEventHandler(pictureBox_MouseDown);
                this.Controls.Add(pictureBox);
                pictureBox.BringToFront();

                MouseUPDOWN();

            }
        }
        void PB_MouseHover(object sender, MouseEventArgs e)
        {
            mouseLocation = this.PointToClient(Cursor.Position);
            pictureBox1.Location = mouseLocation;
            pictureBox1.Show();
            pictureBox1.BringToFront();


        }

        void pictureBox_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                x = e.X;
                y = e.Y;
            }
        }

        void PictureBox_MouseMove(object sender, MouseEventArgs e)
        {
           
           if (e.Button == MouseButtons.Left)
           {

                ((PictureBox)sender).Left += (e.X - x);
                ((PictureBox)sender).Top += (e.Y - y);
                ((PictureBox)sender).BringToFront();
           }
        }

Open in new window

securedungeonAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SriVaddadiCommented:
You have commented the MouseHover event handler registration

//   PB.MouseHover += new MouseEventHandler(PB_MouseHover);
0
securedungeonAuthor Commented:
But there is an  Error : Cannot implicitly convert type 'System.Windows.Forms.MouseEventHandler' to 'System.EventHandler'.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
It should be:

    PB.MouseHover += new EventHandler(PB_MouseHover);

With the method looking like:

        void PB_MouseHover(object sender, EventArgs e)
        {
           
        }
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.