Pen.EndCap 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置要在通过此 Pen 绘制的直线终点使用的线帽样式。
public:
property System::Drawing::Drawing2D::LineCap EndCap { System::Drawing::Drawing2D::LineCap get(); void set(System::Drawing::Drawing2D::LineCap value); };
public System.Drawing.Drawing2D.LineCap EndCap { get; set; }
member this.EndCap : System.Drawing.Drawing2D.LineCap with get, set
Public Property EndCap As LineCap
属性值
LineCap 值之一,表示在通过此 Pen 绘制的直线终点使用的线帽样式。
例外
指定值不是 LineCap 的成员。
示例
下面的代码示例演示在 上Pen设置 StartCap 和 EndCap 属性的效果。
此示例旨在与 Windows 窗体 一起使用。 将代码粘贴到窗体中,并在处理窗体的 Paint 事件时调用 ShowStartAndEndCaps
方法,作为 e
PaintEventArgs传递。
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