CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2003
    Posts
    4

    Question drawing lines and circles

    I have just bought VB.NET and now I want to draw a line but i can't find the line control in the toolbox can you help me ???

  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868
    Use the form's Paint event and the graphics object like this:

    Private Sub Form2_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
    Dim p As Pen
    Dim r As Rectangle
    r = New Rectangle(100, 100, 40, 40)
    p = New Pen(System.Drawing.Color.Red)
    e.Graphics.DrawLine(p, 10, 10, 50, 50)
    e.Graphics.DrawEllipse(p, r)
    End Sub

  3. #3
    Join Date
    May 2002
    Location
    Toronto
    Posts
    167
    or a line on a form is simply a label now with without text and the background colour the colour you want the line

  4. #4
    Join Date
    Jul 2000
    Posts
    70

    Unhappy That works...

    Using a label as a line would work, but it's a bit crude.

    If they just bought .Net, it'd be worth the effort to learn how to use the System.Drawing and System.Drawing.Drawing2d library for doing things like that. It might take some extra work and learning time, but it will allow more functionality, like diagonal lines.

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