CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2009
    Posts
    38

    Create Lines on Form

    I'm wanting to draw a grid on a form using the line control, however it will take me ages to do it by hand! I was wondering how to create and draw lines on a form?

    I tried using:

    Code:
     dim border as line
    border.X1 = 8
    border.Y1 = 8
    ... etc
    But I get an error about the object variable not being set? I've never used code to create objects on a form before, so I'm not really sure what I'm doing!

    Cheers,
    -Sam

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Create Lines on Form

    if you want to draw lines on the form use the Line Method

    Line(x1,y1)-(x2,y2)

    you can also specify a color as well as make it draw a box or a filled box see Line Method in your online help more detail and example.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    May 2009
    Location
    London
    Posts
    51

    Re: Create Lines on Form

    DataMiser is right about the Line method of the form.

    Remember if you are going to use this method you should set the AutoRedraw property of the form to true, otherwise any lines drawn are cleared when the form redraws.

  4. #4
    Join Date
    Apr 2009
    Posts
    38

    Re: Create Lines on Form

    The way my program works I need to use a line object, and give each line an index value, thank you for the suggestion though

  5. #5
    Join Date
    Apr 2009
    Posts
    38

    Re: Create Lines on Form

    I've just figured it out now

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: Create Lines on Form

    Go to the top post, pull down THREAD TOOLS, and MARK it as RESOLVED!!!

    Also, post your solution, for the next person that is looking for the answer. Pay it forward!
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  7. #7
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: Create Lines on Form

    Quote Originally Posted by SamstaUK View Post
    The way my program works I need to use a line object, and give each line an index value, thank you for the suggestion though
    Line object will work just fine. I started to suggest that as well but the line method gives more options and uses fewer resources so in most cases is a better choice.
    Always use [code][/code] tags when posting code.

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

Featured