DashStyle Enumerazione

Definizione

Specifica lo stile delle linee tratteggiate disegnate con un oggetto Pen.

public enum class DashStyle
public enum DashStyle
type DashStyle = 
Public Enum DashStyle
Ereditarietà
DashStyle

Campi

Custom 5

Specifica uno stile tratteggiato personalizzato definito dall'utente.

Dash 1

Specifica una linea composta da trattini.

DashDot 3

Specifica una linea composta da un motivo ripetuto trattino-punto.

DashDotDot 4

Specifica una linea composta da un motivo ripetuto trattino-punto-punto.

Dot 2

Specifica una linea composta da punti.

Solid 0

Specifica una linea continua.

Esempio

Nell'esempio di codice seguente viene illustrato come creare una penna e impostarne la DashStyle proprietà usando l'enumerazione DashStyle .

Questo esempio è progettato per essere usato con Windows Forms. Creare un modulo contenente un Button oggetto denominato Button3. Incollare il codice nel modulo e associare il Button3_Click metodo all'evento del Click pulsante.

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

Commenti

Per definire un oggetto personalizzato DashStyle, impostare la DashPattern proprietà dell'oggetto Pen.

Si applica a

Vedi anche