DashStyle 列舉

定義

指定使用 Pen 物件繪製的虛線樣式。

C#
public enum DashStyle
繼承
DashStyle

欄位

名稱 Description
Custom 5

指定使用者定義的自訂虛線樣式。

Dash 1

指定含有虛線的線條。

DashDot 3

指定含有「虛線-點」之重複花紋的線條。

DashDotDot 4

指定含有「虛線-點-點」之重複花紋的線條。

Dot 2

指定含有點的線條。

Solid 0

指定實線。

範例

下列程式代碼範例示範如何建立畫筆,並使用 列舉來設定其 DashStyle 屬性 DashStyle

此範例的設計目的是要與 Windows Forms 搭配使用。 Create 包含具名 Button3Button表單。 將程式代碼貼到表單中,並將 Button3_Click 方法與按鈕的事件 Click 產生關聯。

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

備註

若要定義自定義 DashStyle,請設定 DashPatternPen屬性。

適用於

產品 版本
.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
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

另請參閱