Share via


DashStyle Enum

Definisi

Menentukan gaya garis putus-putus yang digambar dengan Pen objek .

public enum class DashStyle
public enum DashStyle
type DashStyle = 
Public Enum DashStyle
Warisan
DashStyle

Bidang

Custom 5

Menentukan gaya tanda hubung kustom yang ditentukan pengguna.

Dash 1

Menentukan garis yang terdiri dari tanda hubung.

DashDot 3

Menentukan garis yang terdiri dari pola pengulangan tanda hubung-titik.

DashDotDot 4

Menentukan garis yang terdiri dari pola berulang dari dash-dot-dot.

Dot 2

Menentukan garis yang terdiri dari titik.

Solid 0

Menentukan garis tebal.

Contoh

Contoh kode berikut menunjukkan cara membuat pena dan mengatur propertinya DashStyle menggunakan DashStyle enumerasi.

Contoh ini dirancang untuk digunakan dengan Formulir Windows. Create formulir yang berisi bernama ButtonButton3. Tempelkan kode ke dalam formulir dan kaitkan Button3_Click metode dengan peristiwa tombol 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

Keterangan

Untuk menentukan kustom DashStyle, atur DashPattern properti dari Pen.

Berlaku untuk

Lihat juga