DashStyle 枚举

定义

指定用 Pen 对象绘制的虚线的样式。

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

字段

Custom 5

指定用户定义的自定义划线段样式。

Dash 1

指定由划线段组成的直线。

DashDot 3

指定由重复的划线点图案构成的直线。

DashDotDot 4

指定由重复的划线点点图案构成的直线。

Dot 2

指定由点构成的直线。

Solid 0

指定实线。

示例

下面的代码示例演示如何使用 DashStyle 枚举创建笔并设置其DashStyle属性。

此示例旨在与 Windows 窗体 一起使用。 创建包含名为 的ButtonButton3窗体。 将代码粘贴到窗体中,并将 Button3_Click 方法与按钮的事件 Click 相关联。

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,请设置 DashPatternPen属性。

适用于

另请参阅