# LinePrimitive

**LinePrimitive** is actually a variation of a filled rectangle. The shadow of the fill is set by the **BackColor**, **BackColor2**, **BackColor3** and **BackColor4** properties. The way these four colors are used is determined by the **GradientStyle** and **GradientAngle** properties. The **LineWidth** sets the thickness of the line. Some **GradientStyle** settings will not be visible if the **LineWidth** is too narrow. The example below iterates the possible **GradientStyle** values and creates a **LinePrimitive** for each. The **LinePrimitives** each have a **LineWidth** of 10, making it easier to see the **GradientStyle** effect. The **AngleTransform** property is used to spin the line 30 degrees.

![Telerik UI for WinForms LinePrimitive examples showing gradient styles and a 30-degree angle](https://www.telerik.com/products/winforms/documentation/assets/371dbb0199bb6c7e4c4dfbe4d846f74f/tpf-primitives-lineprimitive001.png)

#### Creating a LinePrimitive

 

 

```C#
public class MyLinePrimitiveElement : RadElement
{
    protected override void CreateChildElements()
    {
        StackLayoutPanel layoutPanel = new StackLayoutPanel();
        layoutPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
        Array gradientStyleValues = Enum.GetValues(typeof(GradientStyles));
        foreach (GradientStyles gradientStyle in gradientStyleValues)
        {
            StackLayoutPanel panel = new StackLayoutPanel();
            panel.Orientation = System.Windows.Forms.Orientation.Vertical;
            panel.Margin = new System.Windows.Forms.Padding(3);
            panel.MinSize = new Size(60, 0);
            LinePrimitive linePrimitive = new LinePrimitive();
            linePrimitive.NumberOfColors = 4;
            linePrimitive.GradientStyle = gradientStyle;
            linePrimitive.BackColor = Color.Blue;
            linePrimitive.BackColor2 = Color.SkyBlue;
            linePrimitive.BackColor3 = Color.Lime;
            linePrimitive.BackColor4 = Color.Green;
            linePrimitive.LineWidth = 10;
            linePrimitive.AngleTransform = 45;
            linePrimitive.MinSize = new Size(40, 30);
            panel.Children.Add(linePrimitive);
            TextPrimitive textPrimitive = new TextPrimitive();
            textPrimitive.Text = gradientStyle.ToString("g");
            textPrimitive.Font = new Font(textPrimitive.Font, FontStyle.Bold);
            textPrimitive.ForeColor = Color.Black;
            textPrimitive.Margin = new System.Windows.Forms.Padding(15, 0, 0, 0);
            panel.Children.Add(textPrimitive);
            layoutPanel.Children.Add(panel);
        }
        this.Children.Add(layoutPanel);
        base.CreateChildElements();
    }
}

```

```VB.NET
Public Class MyLinePrimitiveElement
    Inherits RadElement
    Protected Overrides Sub CreateChildElements()
        Dim layoutPanel As New StackLayoutPanel()
        layoutPanel.Orientation = System.Windows.Forms.Orientation.Horizontal
        Dim gradientStyleValues As Array = System.Enum.GetValues(GetType(GradientStyles))
        For Each gradientStyle As GradientStyles In gradientStyleValues
            Dim panel As New StackLayoutPanel()
            panel.Orientation = System.Windows.Forms.Orientation.Vertical
            panel.Margin = New System.Windows.Forms.Padding(3)
            panel.MinSize = New Size(60, 0)
            Dim linePrimitive As New LinePrimitive()
            linePrimitive.NumberOfColors = 4
            linePrimitive.GradientStyle = gradientStyle
            linePrimitive.BackColor = Color.Blue
            linePrimitive.BackColor2 = Color.SkyBlue
            linePrimitive.BackColor3 = Color.Lime
            linePrimitive.BackColor4 = Color.Green
            linePrimitive.LineWidth = 10
            linePrimitive.AngleTransform = 45
            linePrimitive.MinSize = New Size(40, 30)
            panel.Children.Add(linePrimitive)
            Dim textPrimitive As New TextPrimitive()
            textPrimitive.Text = gradientStyle.ToString("g")
            textPrimitive.Font = New Font(textPrimitive.Font, FontStyle.Bold)
            textPrimitive.ForeColor = Color.Black
            textPrimitive.Margin = New System.Windows.Forms.Padding(15, 0, 0, 0)
            panel.Children.Add(textPrimitive)
            layoutPanel.Children.Add(panel)
        Next gradientStyle
        Me.Children.Add(layoutPanel)
        MyBase.CreateChildElements()
    End Sub
End Class

```



## See Also

* [ArrowPrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/arrowprimitive)

* [BorderPrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/borderprimitive)

* [CheckPrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/checkprimitive)

* [FillPrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/fillprimitive)

* [FocusPrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/focusprimitive)

* [GripPrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/gripprimitive)

* [ImagePrimitive](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/imageprimitive)

* [ImageShape](https://www.telerik.com/products/winforms/documentation/telerik-presentation-framework/primitives/imageshape)
