Results 1 to 6 of 6

Thread: Determine Selected Line

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2013
    Posts
    69

    Determine Selected Line

    Hello all

    I have a line drawn on picturebox.
    Now i want to run some command if a mouse location is on drawn line area.
    How can i do this ?

    Thanks in advance.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Determine Selected Line

    Use the pictureboxe's _mousemove event and compare the mouse location with the x, y location of your line.
    If your line is diagonal, it becomes slightly more difficult, requiring a mathematical formula

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2013
    Posts
    69

    Re: Determine Selected Line

    Like this ?
    Code:
    For Each Line As Line In LineS
          If e.Location.X >= Line.Start.X And e.Location.Y >= Line.Start.Y And _
                    e.Location.X <= Line.End.X And e.Location.Y <= Line.End.Y Then
                    'Some Command
          End If
    Next
    or u have other easiest way ?
    a Line is saved on a List(Of Line) named Lines.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Determine Selected Line

    That could work. Have you tried it?

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2013
    Posts
    69

    Re: Determine Selected Line

    Yea its work. But i just find a easiest way.

  6. #6
    Fanatic Member
    Join Date
    Sep 2002
    Posts
    527

    Re: Determine Selected Line

    Quote Originally Posted by jimzarthur View Post
    Yea its work. But i just find a easiest way.
    Could you share that way with us?

    In case your search isn't over, take a look at this, more specially at post #31 by Boops Boops.
    Last edited by Alain; Sep 15th, 2014 at 07:53 AM.
    Don't ask why, just reboot!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width