DashStyle Wyliczenie

Definicja

Określa styl linii kreskowanych rysowanych obiektem Pen .

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

Pola

Custom 5

Określa niestandardowy styl kreski zdefiniowany przez użytkownika.

Dash 1

Określa linię składającą się z kreski.

DashDot 3

Określa linię składającą się z powtarzającego się wzorca kreski-kropki.

DashDotDot 4

Określa linię składającą się z powtarzającego się wzorca dash-dot-dot..

Dot 2

Określa linię składającą się z kropek.

Solid 0

Określa linię ciągłą.

Przykłady

W poniższym przykładzie kodu pokazano, jak utworzyć pióro i ustawić jego DashStyle właściwość przy użyciu wyliczenia DashStyle .

Ten przykład jest przeznaczony do użycia z Windows Forms. Twórca formularz zawierający Button nazwę Button3. Wklej kod do formularza i skojarz Button3_Click metodę ze zdarzeniem przycisku 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

Uwagi

Aby zdefiniować niestandardowy DashStyleelement , ustaw DashPattern właściwość Pen.

Dotyczy

Zobacz też