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 Forms 搭配使用。 Create 包含具名 Button3Button表單。 將程式代碼貼到表單中,並將 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屬性。

適用於

另請參閱