Export (0) Print
Expand All

DashStyle Enumeration

Specifies the style of dashed lines drawn with a Pen object.

Namespace: System.Drawing.Drawing2D
Assembly: System.Drawing (in system.drawing.dll)

public enum DashStyle
public enum DashStyle
public enum DashStyle

 Member nameDescription
CustomSpecifies a user-defined custom dash style. 
Supported by the .NET Compact FrameworkDashSpecifies a line consisting of dashes. 
DashDotSpecifies a line consisting of a repeating pattern of dash-dot. 
DashDotDotSpecifies a line consisting of a repeating pattern of dash-dot-dot. 
DotSpecifies a line consisting of dots. 
Supported by the .NET Compact FrameworkSolidSpecifies a solid line. 

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 void Button3_Click(System.Object sender, System.EventArgs e)
{

    Graphics buttonGraphics = Button3.CreateGraphics();
    Pen myPen = new Pen(Color.ForestGreen, 4.0F);
    myPen.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot;

    Rectangle theRectangle = Button3.ClientRectangle;
    theRectangle.Inflate(-2, -2);
    buttonGraphics.DrawRectangle(myPen, theRectangle);
    buttonGraphics.Dispose();
    myPen.Dispose();
}

private void button3_Click(Object sender, System.EventArgs e)
{
    Graphics buttonGraphics = button3.CreateGraphics();
    Pen myPen = new Pen(Color.get_ForestGreen(), 4.0F);

    myPen.set_DashStyle(System.Drawing.Drawing2D.DashStyle.DashDotDot);

    Rectangle theRectangle = button3.get_ClientRectangle();

    theRectangle.Inflate(-2, -2);
    buttonGraphics.DrawRectangle(myPen, theRectangle);
    buttonGraphics.Dispose();
    myPen.Dispose();
} //button3_Click

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft