DashStyle DashStyle DashStyle DashStyle Enum

定义

指定用 Pen 对象绘制的虚线的样式。Specifies the style of dashed lines drawn with a Pen object.

public enum class DashStyle
public enum DashStyle
type DashStyle = 
Public Enum DashStyle
继承

字段

Custom Custom Custom Custom 5

指定用户定义的自定义划线段样式。Specifies a user-defined custom dash style.

Dash Dash Dash Dash 1

指定由划线段组成的直线。Specifies a line consisting of dashes.

DashDot DashDot DashDot DashDot 3

指定由重复的划线点图案构成的直线。Specifies a line consisting of a repeating pattern of dash-dot.

DashDotDot DashDotDot DashDotDot DashDotDot 4

指定由重复的划线点点图案构成的直线。Specifies a line consisting of a repeating pattern of dash-dot-dot.

Dot Dot Dot Dot 2

指定由点构成的直线。Specifies a line consisting of dots.

Solid Solid Solid Solid 0

指定实线。Specifies a solid line.

示例

下面的代码示例演示如何DashStyle DashStyle使用枚举来创建笔并设置其属性。The following code example demonstrates how to create a pen and set its DashStyle property using the DashStyle enumeration.

此示例旨在与 Windows 窗体一起使用。This example is designed to be used with Windows Forms. 创建一个包含Button名为Button3的窗体。Create a form that contains a Button named Button3. 将代码粘贴到窗体中, 并Button3_Click将该方法与按钮Click的事件关联。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;
   }
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 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

注解

若要定义自DashStyle定义, 请DashPattern设置的Pen属性。To define a custom DashStyle, set the DashPattern property of the Pen.

适用于

另请参阅