DashStyle Enum
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Menentukan gaya garis putus-putus yang digambar dengan objek Pen.
public enum class DashStyle
public enum DashStyle
type DashStyle =
Public Enum DashStyle
- Warisan
Bidang
| Nama | Nilai | Deskripsi |
|---|---|---|
| Solid | 0 | Menentukan garis padat. |
| Dash | 1 | Menentukan garis yang terdiri dari tanda hubung. |
| Dot | 2 | Menentukan garis yang terdiri dari titik-titik. |
| DashDot | 3 | Menentukan garis yang terdiri dari pola berulang titik putus-putus. |
| DashDotDot | 4 | Menentukan garis yang terdiri dari pola berulang tanda hubung-titik-titik. |
| Custom | 5 | Menentukan gaya tanda hubung kustom yang ditentukan pengguna. |
Contoh
Contoh kode berikut menunjukkan cara membuat pena dan mengatur propertinya DashStyle menggunakan DashStyle enumerasi.
Contoh ini dirancang untuk digunakan dengan Windows Forms. Buat 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 .Pen