0

I want to draw lines on winforms and add hover event to each one of them. this is the code I have so far

    private void Form2_Paint(object sender, PaintEventArgs e)
    {
        Graphics g;

        g = e.Graphics;

        Pen myPen = new Pen(Color.Black);
        myPen.Width = 3;

        g.DrawLine(myPen, 30, 30, 45, 65);

        g.DrawLine(myPen, 1, 1, 45, 65);
    }
  • You can't. You'll have to do it yourself from mouse location – Sami Kuhmonen Nov 26 '16 at 09:36
  • You have to handle `MouseHover` event of the form (https://msdn.microsoft.com/en-us/library/system.windows.forms.control.mousehover(v=vs.110).aspx), and check if current mouse coordinates belong to line (see this question, for example: http://stackoverflow.com/questions/7050186/find-if-point-lays-on-line-segment). – Dennis Nov 26 '16 at 09:37

0 Answers0