Pen.StartCap 属性

定义

获取或设置在通过此 Pen 绘制的直线起点使用的线帽样式。

public:
 property System::Drawing::Drawing2D::LineCap StartCap { System::Drawing::Drawing2D::LineCap get(); void set(System::Drawing::Drawing2D::LineCap value); };
public System.Drawing.Drawing2D.LineCap StartCap { get; set; }
member this.StartCap : System.Drawing.Drawing2D.LineCap with get, set
Public Property StartCap As LineCap

属性值

LineCap 值之一,表示在通过此 Pen 绘制的直线起点使用的线帽样式。

例外

指定值不是 LineCap 的成员。

对不可变的 StartCap(比如由 Pen 类所返回)设置 Pens 属性。

示例

下面的代码示例演示在 上Pen设置 StartCapEndCap 属性的效果。

此示例旨在与 Windows 窗体 一起使用。 将代码粘贴到窗体中, ShowStartAndEndCaps 并在处理窗体 Paint 的事件时调用 方法,作为 ePaintEventArgs传递。

private:
   void ShowStartAndEndCaps( PaintEventArgs^ e )
   {
      // Create a new custom pen.
      Pen^ redPen = gcnew Pen( Brushes::Red,6.0F );

      // Set the StartCap property.
      redPen->StartCap = System::Drawing::Drawing2D::LineCap::RoundAnchor;

      // Set the EndCap property.
      redPen->EndCap = System::Drawing::Drawing2D::LineCap::ArrowAnchor;

      // Draw a line.
      e->Graphics->DrawLine( redPen, 40.0F, 40.0F, 145.0F, 185.0F );

      // Dispose of the custom pen.
      delete redPen;
   }
private void ShowStartAndEndCaps(PaintEventArgs e)
{

    // Create a new custom pen.
    Pen redPen = new Pen(Brushes.Red, 6.0F);

    // Set the StartCap property.
    redPen.StartCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;

    // Set the EndCap property.
    redPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;

    // Draw a line.
    e.Graphics.DrawLine(redPen, 40.0F, 40.0F, 145.0F, 185.0F);

    // Dispose of the custom pen.
    redPen.Dispose();
}
Private Sub ShowStartAndEndCaps(ByVal e As PaintEventArgs)

    ' Create a new custom pen.
    Dim redPen As New Pen(Brushes.Red, 6.0F)

    ' Set the StartCap property.
    redPen.StartCap = Drawing2D.LineCap.RoundAnchor

    ' Set the EndCap property.
    redPen.EndCap = Drawing2D.LineCap.ArrowAnchor

    ' Draw a line.
    e.Graphics.DrawLine(redPen, 40.0F, 40.0F, 145.0F, 185.0F)

    ' Dispose of the custom pen.
    redPen.Dispose()

End Sub

适用于