Pen.Width 属性 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
public:
 property float Width { float get(); void set(float value); };public float Width { get; set; }member this.Width : single with get, setPublic Property Width As Single属性值
此 Pen 的宽度。
例外
示例
下面的代码示例演示在 上Pen设置 Width 和 LineJoin 属性的效果。
此示例旨在与 Windows 窗体 一起使用。 将代码粘贴到窗体中,并在处理窗体的 Paint 事件时调用 ShowLineJoin 方法,作为 ePaintEventArgs传递。
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
注解
可以使用对象的 属性访问对象的GraphicsPageUnit度量单位。 度量单位通常是像素。 如果 Width 为 0, Pen 则会导致绘图,就像 Width 是 1 一样。