LineCap LineCap LineCap LineCap Enum


指定可用线帽样式,Pen 对象以该线帽结束一段直线。Specifies the available cap styles with which a Pen object can end a line.

public enum class LineCap
public enum LineCap
type LineCap = 
Public Enum LineCap


AnchorMask AnchorMask AnchorMask AnchorMask 240

指定用于检查线帽是否为锚头帽的掩码。Specifies a mask used to check whether a line cap is an anchor cap.

ArrowAnchor ArrowAnchor ArrowAnchor ArrowAnchor 20

指定箭头状锚头帽。Specifies an arrow-shaped anchor cap.

Custom Custom Custom Custom 255

指定自定义线帽。Specifies a custom line cap.

DiamondAnchor DiamondAnchor DiamondAnchor DiamondAnchor 19

指定菱形锚头帽。Specifies a diamond anchor cap.

Flat Flat Flat Flat 0

指定平线帽。Specifies a flat line cap.

NoAnchor NoAnchor NoAnchor NoAnchor 16

指定没有锚。Specifies no anchor.

Round Round Round Round 2

指定圆线帽。Specifies a round line cap.

RoundAnchor RoundAnchor RoundAnchor RoundAnchor 18

指定圆锚头帽。Specifies a round anchor cap.

Square Square Square Square 1

指定方线帽。Specifies a square line cap.

SquareAnchor SquareAnchor SquareAnchor SquareAnchor 17

指定方锚头帽。Specifies a square anchor line cap.

Triangle Triangle Triangle Triangle 3

指定三角线帽。Specifies a triangular line cap.


下面的示例在一端绘制一个箭头, 并在另一端绘制一个圆角端。The following example draws a line with an arrowhead at one end and a round cap at the other end. 若要运行此示例, 请创建一个 Windows 窗体并处理Paint窗体的事件。To run this example, Create a Windows Form and handle the form's Paint event. 将示例代码粘贴到作为Paint PaintEventArgs传递e的事件处理程序中。Paste the example code into the Paint event handler passing e as PaintEventArgs.

Pen pen = new Pen(Color.FromArgb(255, 0, 0, 255), 8);
pen.StartCap = LineCap.ArrowAnchor;
pen.EndCap = LineCap.RoundAnchor;
e.Graphics.DrawLine(pen, 20, 175, 300, 175);
Dim pen As New Pen(Color.FromArgb(255, 0, 0, 255), 8)
pen.StartCap = LineCap.ArrowAnchor
pen.EndCap = LineCap.RoundAnchor
e.Graphics.DrawLine(pen, 20, 175, 300, 175)


您可以在多个名为 "线帽" 的形状之一中绘制线条的开头或结尾。You can draw the start or end of a line in one of several shapes called line caps. GDI+GDI+支持多个行帽, 如圆形、方形、菱形和箭头。supports several line caps, such as round, square, diamond, and arrowhead. 下图显示了一个具有圆角端和箭头帽的线条。The following illustration shows a line with a round cap and an arrow cap.