共用方式為


Pen.SetLineCap(LineCap, LineCap, DashCap) 方法

定義

設定值,這個值會決定用來結束此 Pen繪製之線條的上限樣式。

public:
 void SetLineCap(System::Drawing::Drawing2D::LineCap startCap, System::Drawing::Drawing2D::LineCap endCap, System::Drawing::Drawing2D::DashCap dashCap);
public void SetLineCap (System.Drawing.Drawing2D.LineCap startCap, System.Drawing.Drawing2D.LineCap endCap, System.Drawing.Drawing2D.DashCap dashCap);
member this.SetLineCap : System.Drawing.Drawing2D.LineCap * System.Drawing.Drawing2D.LineCap * System.Drawing.Drawing2D.DashCap -> unit
Public Sub SetLineCap (startCap As LineCap, endCap As LineCap, dashCap As DashCap)

參數

startCap
LineCap

LineCap,表示要在這個 Pen繪製之線條開頭使用的上限樣式。

endCap
LineCap

LineCap,表示要在這個 Pen繪製之線條結尾使用的上限樣式。

dashCap
DashCap

LineCap,表示在以這個 Pen繪製之虛線開頭或結尾使用的上限樣式。

範例

下列程式代碼範例是專為搭配 Windows Forms 使用而設計,而且需要 PaintEventArgse,這是 Paint 事件處理程式的參數。 程序代碼會建立 Pen,並將其設定為在行開頭繪製箭頭錨點上限:

public:
   void SetLineCap_Example( PaintEventArgs^ e )
   {
      
      // Create a Pen object with a dash pattern.
      Pen^ capPen = gcnew Pen( Color::Black,5.0f );
      capPen->DashStyle = DashStyle::Dash;
      
      // Set the start and end caps for capPen.
      capPen->SetLineCap( LineCap::ArrowAnchor, LineCap::Flat, DashCap::Flat );
      
      // Draw a line with capPen.
      e->Graphics->DrawLine( capPen, 10, 10, 200, 10 );
   }
public void SetLineCap_Example(PaintEventArgs e)
{
             
    // Create a Pen object with a dash pattern.
    Pen capPen = new Pen(Color.Black, 5);
    capPen.DashStyle = DashStyle.Dash;
             
    // Set the start and end caps for capPen.
    capPen.SetLineCap(LineCap.ArrowAnchor, LineCap.Flat, DashCap.Flat);
             
    // Draw a line with capPen.
    e.Graphics.DrawLine(capPen, 10, 10, 200, 10);
}
Public Sub SetLineCap_Example(ByVal e As PaintEventArgs)

    ' Create a Pen object with a dash pattern.
    Dim capPen As New Pen(Color.Black, 5)
    capPen.DashStyle = DashStyle.Dash

    ' Set the start and end caps for capPen.
    capPen.SetLineCap(LineCap.ArrowAnchor, LineCap.Flat, DashCap.Flat)

    ' Draw a line with capPen.
    e.Graphics.DrawLine(capPen, 10, 10, 200, 10)
End Sub

適用於