Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1209
  • Last Modified:

How do i draw a dotted line in VB 2008 Express?

Include all code including Form1 class, etc.
0
NerdsOfTech
Asked:
NerdsOfTech
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Create a New Pen with your desired color/width and then set the DashStyle:
http://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.dashstyle.aspx

Simple example:
Imports System.Drawing.Drawing2D
Public Class Form1
 
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim myPen As Pen = New Pen(Color.Black, 1)
        myPen.DashStyle = DashStyle.Dash
        e.Graphics.Drawline(myPen, 25, 25, 100, 50) ' draw dashed line from (25, 25) to (100, 50)
        myPen.Dispose()
    End Sub
 
End Class

Open in new window

0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
The dash is more visible if you use a WIDER Pen:
Imports System.Drawing.Drawing2D
Public Class Form1
 
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim myPen As Pen = New Pen(Color.Black, 4)
        myPen.DashStyle = DashStyle.DashDotDot
        e.Graphics.DrawLine(myPen, 25, 25, 500, 500) ' draw dashed line from (25, 25) to (100, 50)
        myPen.Dispose()
    End Sub
 
End Class

Open in new window

DashedLine.jpg
0
 
NerdsOfTechTechnology ScientistAuthor Commented:
Super Awesome! Thanks for the image too very nice to see it working in the shot!
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now