-
Nov 27th, 2020, 02:11 AM
#1
Thread Starter
New Member
Create custom line in vb.net
Is there a way to create custom lines in vb.net?
I cannot find a way to do so and it would be really helpful if any of you could help me.
Thank you.
-
Nov 27th, 2020, 03:14 AM
#2
Re: Create custom line in vb.net
Where do you want to draw the line? On your form? If so, you just use the form’s paint event. The eventargs has a graphics object. You use the graphics object drawline method...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 27th, 2020, 04:35 AM
#3
Re: Create custom line in vb.net
yes you can, as said by .paul. , you draw in the pain event : here is an example with the form1 paint event from https://www.worldbestlearningcenter....wing-lines.htm
it works with all paint event of controls (picturebox, button, etc)
Code:
Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
'Create point objects
Dim pt As New Point(50, 50)
Dim pt1 As New Point(300, 50)
Dim pt2 As New Point(200, 70)
Dim pt3 As New Point(50, 170)
Dim pt4 As New Point(300, 170)
Dim pt5 As New Point(200, 70)
'Array of points
Dim pArra() As Point = {pt2, pt3, pt4, pt5}
'Draw a line
e.Graphics.DrawLine(Pens.Orange, pt, pt1)
'Draw multiple lines
e.Graphics.DrawLines(Pens.Blue, pArra)
End Sub
Last edited by Delaney; Nov 27th, 2020 at 04:41 AM.
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
-
Nov 28th, 2020, 12:47 PM
#4
Re: Create custom line in vb.net
Also, if you want to be interacting with the line, look into the GraphicsPath object. You can draw lines with that, and be better able to deal with mouse events.
My usual boring signature: Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|