DashStyle Enumeration
Updated: October 2008
Specifies the style of dashed lines drawn with a Pen object.
Assembly: System.Drawing (in System.Drawing.dll)
| Member name | Description | |
|---|---|---|
![]() | Solid | Specifies a solid line. |
![]() | Dash | Specifies a line consisting of dashes. |
| Dot | Specifies a line consisting of dots. | |
| DashDot | Specifies a line consisting of a repeating pattern of dash-dot. | |
| DashDotDot | Specifies a line consisting of a repeating pattern of dash-dot-dot. | |
| Custom | Specifies a user-defined custom dash style. |
To define a custom DashStyle, set the DashPattern property of the Pen.
The following code example demonstrates how to create a pen and set its DashStyle property using the DashStyle enumeration.
This example is designed to be used with Windows Forms. Create a form that contains a Button named Button3. Paste the code into the form and associate the Button3_Click method with the button's Click event.
Private Sub Button3_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button3.Click Dim buttonGraphics As Graphics = Button3.CreateGraphics() Dim myPen As Pen = New Pen(Color.ForestGreen, 4.0F) myPen.DashStyle = Drawing2D.DashStyle.DashDotDot Dim theRectangle As Rectangle = Button3.ClientRectangle theRectangle.Inflate(-2, -2) buttonGraphics.DrawRectangle(myPen, theRectangle) buttonGraphics.Dispose() myPen.Dispose() End Sub
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
