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 窗体,它需要 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

适用于