DashStyle 列挙型

定義

Pen オブジェクトで描画する破線のスタイルを指定します。

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

フィールド

Custom 5

ユーザー定義のカスタム ダッシュ スタイルを指定します。

Dash 1

ダッシュで構成される直線を指定します。

DashDot 3

ダッシュとドットの繰り返しパターンで構成される直線を指定します。

DashDotDot 4

ダッシュと 2 つのドットの繰り返しパターンで構成される直線を指定します。

Dot 2

ドットで構成される直線を指定します。

Solid 0

実線を指定します。

次のコード例では、 列挙体を使用してペンを作成し、そのプロパティを DashStyle 設定する方法を DashStyle 示します。

この例は、Windows フォームで使用するように設計されています。 という名前Button3の を含むフォームをButton作成します。 コードをフォームに貼り付け、 メソッドを 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を定義するには、 の プロパティを DashPattern 設定します Pen

適用対象

こちらもご覧ください