Przeczytaj w języku angielskim Edytuj

Udostępnij za pośrednictwem


DashStyle Enum

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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

C#
public enum DashStyle
Inheritance
DashStyle

Fields

Name Value Description
Solid 0

Specifies a solid line.

Dash 1

Specifies a line consisting of dashes.

Dot 2

Specifies a line consisting of dots.

DashDot 3

Specifies a line consisting of a repeating pattern of dash-dot.

DashDotDot 4

Specifies a line consisting of a repeating pattern of dash-dot-dot.

Custom 5

Specifies a user-defined custom dash style.

Examples

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.

C#
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();
}

Remarks

To define a custom DashStyle, set the DashPattern property of the Pen.

Applies to

Produkt Wersje
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also