Pen.Width 속성

정의

그리는 데 사용된 Pen 개체의 단위로 이 Graphics의 너비를 가져오거나 설정합니다.

public:
 property float Width { float get(); void set(float value); };
public float Width { get; set; }
member this.Width : single with get, set
Public Property Width As Single

속성 값

Pen의 너비입니다.

예외

Width 클래스에서 반환된 것과 같은 변경 불가능한 PenPens 속성을 설정한 경우

예제

다음 코드 예제에서는 설정 Width 의 효과 보여 줍니다 합니다 및 LineJoin 속성에 합니다 Pen.

이 예제는 Windows Forms 함께 사용하도록 설계되었습니다. 폼에 코드를 붙여넣고 양식의 Paint 이벤트를 처리할 때 메서드를 호출 ShowLineJoin 하여 으로 PaintEventArgs전달합니다e.

private:
   void ShowLineJoin( PaintEventArgs^ e )
   {
      // Create a new pen.
      Pen^ skyBluePen = gcnew Pen( Brushes::DeepSkyBlue );

      // Set the pen's width.
      skyBluePen->Width = 8.0F;

      // Set the LineJoin property.
      skyBluePen->LineJoin = System::Drawing::Drawing2D::LineJoin::Bevel;

      // Draw a rectangle.
      e->Graphics->DrawRectangle( skyBluePen, Rectangle(40,40,150,200) );

      //Dispose of the pen.
      delete skyBluePen;
   }
private void ShowLineJoin(PaintEventArgs e)
{

    // Create a new pen.
    Pen skyBluePen = new Pen(Brushes.DeepSkyBlue);

    // Set the pen's width.
    skyBluePen.Width = 8.0F;

    // Set the LineJoin property.
    skyBluePen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel;

    // Draw a rectangle.
    e.Graphics.DrawRectangle(skyBluePen, 
        new Rectangle(40, 40, 150, 200));

    //Dispose of the pen.
    skyBluePen.Dispose();
}
Private Sub ShowLineJoin(ByVal e As PaintEventArgs)

    ' Create a new pen.
    Dim skyBluePen As New Pen(Brushes.DeepSkyBlue)

    ' Set the pen's width.
    skyBluePen.Width = 8.0F

    ' Set the LineJoin property.
    skyBluePen.LineJoin = Drawing2D.LineJoin.Bevel

    ' Draw a rectangle.
    e.Graphics.DrawRectangle(skyBluePen, _
        New Rectangle(40, 40, 150, 200))

    'Dispose of the pen.
    skyBluePen.Dispose()

End Sub

설명

해당 PageUnit 속성을 사용하여 개체의 측정 단위에 Graphics 액세스할 수 있습니다. 측정 단위는 일반적으로 픽셀입니다. Width 가 0이면 가 1인 것처럼 드로잉이 Width 생성 Pen 됩니다.

적용 대상