DashStyle Enumeration
.NET Framework (current version)
Specifies the style of dashed lines drawn with a Pen object.
Assembly: System.Drawing (in System.Drawing.dll)
| Member name | Description | |
|---|---|---|
| Custom | Specifies a user-defined custom dash style. | |
| Dash | Specifies a line consisting of dashes. | |
| 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. | |
| Dot | Specifies a line consisting of dots. | |
| Solid | Specifies a solid line. |
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: void Button3_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ ) { Graphics^ buttonGraphics = Button3->CreateGraphics(); Pen^ myPen = gcnew Pen( Color::ForestGreen,4.0F ); myPen->DashStyle = System::Drawing::Drawing2D::DashStyle::DashDotDot; Rectangle theRectangle = Button3->ClientRectangle; theRectangle.Inflate( -2, -2 ); buttonGraphics->DrawRectangle( myPen, theRectangle ); delete buttonGraphics; delete myPen; }
.NET Framework
Available since 1.1
Available since 1.1
Show: