Results 1 to 9 of 9

Thread: Line control gone in VB.NET (diagonal line)

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830

    Line control gone in VB.NET (diagonal line)

    Hello,

    In VB6 you could use the line control to draw a diagonal line. How do you do it in .NET?

    Thanks!

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,683
    Either write your own line control or...

    me.CreateGraphics.DrawLine(...)
    I don't live here any more.

  3. #3
    Registered User NicoNel2000's Avatar
    Join Date
    Feb 2004
    Location
    Beijing - China
    Posts
    296
    So no more line control? NOt that it was a control, but still....

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,683
    Actually, it was a control, but it would take all of half an hour to devise a .net version. And, this is in fact, what I am now going to do.

  5. #5
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    If you need a 3D line to divide sections you can use a label.
    Give it a 3d border and a height or width of 2.

    You can also draw a simple line like that. Just use single border and set height or width to 1.

    Only one prob. You can't select the color...
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  6. #6
    Registered User NicoNel2000's Avatar
    Join Date
    Feb 2004
    Location
    Beijing - China
    Posts
    296
    Gr8 idea pax!

    Gonna share that woss?

  7. #7
    Member
    Join Date
    Sep 2004
    Location
    Oklahoma City, OK
    Posts
    36

    Exclamation

    If you're trying to draw a line on a Windows Form control, here's one way of doing it:

    VB Code:
    1. Imports System.Windows.Forms
    2. Imports System.Drawing
    3. Imports System.Drawing.Drawing2D
    4.  
    5. Sub DrawALineOnAControl(ByRef Sender As Control, ByVal pStart As Point, ByVal pEnd As Point)
    6.     Dim blackPen As Pen = New Pen(Color.Red, 1)
    7.     Dim controlGraphics As Graphics = Sender.CreateGraphics()
    8.    
    9.     controlGraphics.DrawLine(blackPen, pStart, pEnd)
    10.     blackPen.Dispose()
    11.     controlGraphics.Dispose()
    12. End Sub

    Let me know if that helps...

    T

  8. #8
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,683
    Originally posted by tcorey08
    Dim blackPen As Pen = New Pen(Color.Red, 1)


    My line control, if I get time to do it will be part of the Sandpaper library (See Project Comms forum).
    I don't live here any more.

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2003
    Posts
    830
    The drawing in code thing is fine, but with the line as a control it could be resized easily with the application I am using. This also has to be a diagonal line.

    That project wossname is possibly doing sounds good.

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