Results 1 to 4 of 4

Thread: Create custom line in

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2020

    Create custom line in

    Is there a way to create custom lines in
    I cannot find a way to do so and it would be really helpful if any of you could help me.
    Thank you.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Chelmsford UK

    Re: Create custom line in

    Where do you want to draw the line? On your form? If so, you just use the formís paint event. The eventargs has a graphics object. You use the graphics object drawline method...

  3. #3
    Hyperactive Member Delaney's Avatar
    Join Date
    Nov 2019
    Paris, France

    Re: Create custom line in

    yes you can, as said by .paul. , you draw in the pain event : here is an example with the form1 paint event from https://www.worldbestlearningcenter....wing-lines.htm

    it works with all paint event of controls (picturebox, button, etc)

    Private  Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint      
        'Create point objects      
        Dim pt As New Point(50, 50)      
        Dim pt1 As New Point(300, 50)      
        Dim pt2 As New Point(200, 70)      
        Dim pt3 As New Point(50, 170)      
        Dim pt4 As New Point(300, 170)      
        Dim pt5 As New Point(200, 70)      
        'Array of points      
        Dim pArra() As Point = {pt2, pt3, pt4, pt5}      
        'Draw a line      
        e.Graphics.DrawLine(Pens.Orange, pt, pt1)      
        'Draw multiple lines      
        e.Graphics.DrawLines(Pens.Blue, pArra)      
    End Sub
    Last edited by Delaney; Nov 27th, 2020 at 04:41 AM.
    The best friend of any programmer is a search engine
    "Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002

    Re: Create custom line in

    Also, if you want to be interacting with the line, look into the GraphicsPath object. You can draw lines with that, and be better able to deal with mouse events.
    My usual boring signature: Nothing

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