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。
範例
以下程式碼範例展示了將 和 StartCap 屬性設定EndCap在 Pen。
此範例設計用於 Windows 表單。 將程式碼貼到表單中,處理表單ShowStartAndEndCaps事件時呼叫該Paint方法,傳遞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