Pen.StartCap 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定帽緣樣式,用於以這個 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 的成員。
範例
下列程式代碼範例示範在 上Pen設定 StartCap 和 EndCap 屬性的效果。
此範例的設計目的是要與 Windows Forms 搭配使用。 將程式代碼貼到表單中,並在處理表單的事件時呼叫 ShowStartAndEndCaps
方法,並e
傳遞為 PaintEventArgs。Paint
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