Results 1 to 6 of 6

Thread: How to draw a thick arrow in picturebox in vb.net

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2011
    Posts
    137

    How to draw a thick arrow in picturebox in vb.net

    Hello I have here a problem with drawing on the picture.
    Draw a picture on well but it's drawing a thin line and I need a thicker thickness of at least 4.5.

    But I'd like to draw arrow and not line.

    Need a simple arrows with no gradient and a much smaller and thinner.
    Approximately 4.5 thickness used on the image.

    I need normal arrow like in the picture i want to draw arrow anywhere on the image in the picturebox inside like in the paint.

    Or make a bold line of the same code which I gave.
    I'new for graphics so do not ask to me how ?

    Here's an example of what I need.





    how do i do that ?


    So far, I have only this code.
    Here is the code:

    Code:
      Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
            If _Previous IsNot Nothing Then
                If PictureBox1.Image Is Nothing Then
                    Dim bmp As New Bitmap(PictureBox1.Width, PictureBox1.Height)
                    Using g As Graphics = Graphics.FromImage(bmp)
                        g.Clear(Color.White)
                    End Using
                    PictureBox1.Image = bmp
                End If
                Using g As Graphics = Graphics.FromImage(PictureBox1.Image)
                    g.DrawLine(Pens.Red, _Previous.Value, e.Location)
                End Using
                PictureBox1.Invalidate()
                _Previous = e.Location
            End If
        End Sub
     
        Private _Previous As System.Nullable(Of Point) = Nothing
        Private Sub pictureBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox1.MouseDown
            _Previous = e.Location
            PictureBox1_MouseMove(sender, e)
        End Sub
    
    Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
            _Previous = Nothing
        End Sub
    Any help would benefit me.
    Last edited by polas; Oct 14th, 2013 at 11:56 AM.

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: How to draw a thick arrow in picturebox in vb.net

    Why not use that very picture as your arrow instead of trying to draw it yourself. Its the perfect solution based on your description of your problem.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2011
    Posts
    137

    Re: How to draw a thick arrow in picturebox in vb.net

    I want draw that arrow not simple to add like stunned stone yuo know what i mean now and what i want now title says everything.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: How to draw a thick arrow in picturebox in vb.net

    try something like this:

    Code:
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Using linePen As New Pen(Color.Red, 10)
            'draw an arrow head
            Dim gp As New Drawing.Drawing2D.GraphicsPath
            gp.AddLine(0, 3, 3, -5)
            gp.AddLine(0, 3, -3, -5)
            gp.AddLine(-3, -5, 3, -5)
            'fillpath + strokepath can't be used simultaneously
            linePen.CustomEndCap = New Drawing2D.CustomLineCap(gp, Nothing)
            e.Graphics.DrawLine(linePen, 50, 50, 200, 50)
        End Using
    End Sub

  5. #5
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: How to draw a thick arrow in picturebox in vb.net

    Quote Originally Posted by polas View Post
    I want draw that arrow not simple to add like stunned stone yuo know what i mean now and what i want now title says everything.
    You can find tonnes of other arrow images online. It would be way easier and more aesthetically pleasing than trying to draw it yourself.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: How to draw a thick arrow in picturebox in vb.net

    @Niya

    The arrow head is drawn pointing upwards + using it as a CustomLineCap changes the orientation

Tags for this Thread

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