Export (0) Print
Expand All

LineCap Enumeration

Specifies the available cap styles with which a Pen object can end a line.

Namespace:  System.Drawing.Drawing2D
Assembly:  System.Drawing (in System.Drawing.dll)

public enum LineCap

Member nameDescription
AnchorMaskSpecifies a mask used to check whether a line cap is an anchor cap.
ArrowAnchorSpecifies an arrow-shaped anchor cap.
CustomSpecifies a custom line cap.
DiamondAnchorSpecifies a diamond anchor cap.
FlatSpecifies a flat line cap.
NoAnchorSpecifies no anchor.
RoundSpecifies a round line cap.
RoundAnchorSpecifies a round anchor cap.
SquareSpecifies a square line cap.
SquareAnchorSpecifies a square anchor line cap.
TriangleSpecifies a triangular line cap.

You can draw the start or end of a line in one of several shapes called line caps. 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.


The following example draws a line with an arrowhead at one end and a round cap at the other end. To run this example, Create a Windows Form and handle the form's Paint event. 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);

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft