none
Modify Lineshape control RRS feed

  • Question

  • Hi Everyone:

    I am using vb.net 2019.  I have also installed the Line Shape control from the VB Power Pack.  I was wondering if there is anyway of modifying this control to display as arrows instead of just a line.  I am trying to simulate the arrow shape in MS word.  I basically need to change the line width, the arrowhead size on either side (and be able to move it.  I have already found a site that shows how to move a line shape).  Thanks;

    bob 

    Friday, July 12, 2019 2:24 AM

All replies

  • Hi,

    You can draw a  line with an arrow,

      Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
            Dim g As Graphics = e.Graphics
            g.SmoothingMode = SmoothingMode.AntiAlias
            g.FillRectangle(Brushes.White, Me.ClientRectangle)
            Dim p As Pen = New Pen(Color.Black, 1)
            p.StartCap = LineCap.Round
            p.EndCap = LineCap.ArrowAnchor
            g.DrawLine(p, 30, 30, 80, 30)
            p.Dispose()
        End Sub

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 12, 2019 3:04 AM
    Moderator
  • Hi Alex:

    Thanks for the reply.  However that was not my question.  I know how to draw lines and arrows using the graphics class.  My question was specific to the LineShape control.  Is there a way to modify the LineShape control to display and arrow, instead of a line?  thanks.

    Bob

    Friday, July 12, 2019 5:39 PM
  • Hi,

    You can draw on the control with the following way:

    Imports System.Drawing.Drawing2D
    
    Public Class Form1
    
        Private Sub Form1_Paint(sender As Object, e As PaintEventArgs) Handles MyBase.Paint
            Dim g As Graphics = e.Graphics
            g.SmoothingMode = SmoothingMode.AntiAlias
            g.FillRectangle(Brushes.White, Me.ClientRectangle)
            Dim p As Pen = New Pen(Color.Black, 1)
            p.StartCap = LineCap.Round
            p.EndCap = LineCap.ArrowAnchor
            g.DrawLine(p, LineShape1.StartPoint.X, LineShape1.StartPoint.Y, LineShape1.EndPoint.X, LineShape1.EndPoint.Y)
            p.Dispose()
        End Sub
    
    End Class
    


    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 15, 2019 3:25 AM
    Moderator