共用方式為


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 Forms 搭配使用。 將程式代碼貼到表單中,並在處理表單的事件時呼叫 ShowStartAndEndCaps 方法,並e傳遞為 PaintEventArgsPaint

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

適用於