Share via


LineShape.X2 Property

Gets or sets the X coordinate of the ending point of a line drawn by a LineShape control.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'Declaration
<BrowsableAttribute(True)> _
Public Property X2 As Integer
[BrowsableAttribute(true)]
public int X2 { get; set; }
[BrowsableAttribute(true)]
public:
property int X2 {
    int get ();
    void set (int value);
}
[<BrowsableAttribute(true)>]
member X2 : int with get, set
function get X2 () : int 
function set X2 (value : int)

Property Value

Type: Int32
An Integer that represents the X (horizontal) coordinate of the ending point of the line.

Remarks

The coordinate is relative to the container of the LineShape control and is expressed in pixels.

You can also change the ending coordinates by setting the EndPoint property.

Examples

The following example demonstrates how to change the direction of a diagonal line by changing the X1, Y1, X2, and Y2 properties.

Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Dim line1 As New Microsoft.VisualBasic.PowerPacks.LineShape(10, 10,
    200, 10)
Private Sub LineDirection_Load(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles MyBase.Load
    ' Set the form as the parent of the ShapeContainer.
    canvas.Parent = Me 
    ' Set the ShapeContainer as the parent of the LineShape.
    line1.Parent = canvas
End Sub 
Private Sub LineDirection_Click(ByVal sender As Object,
    ByVal e As System.EventArgs) Handles Me.Click
    ChangeDirection()
End Sub 
Private Sub ChangeDirection()
    If line1.X1 = line1.Y2 Then
        line1.X2 = 10
        line1.Y2 = 200
    Else
        line1.X2 = 200
        line1.Y2 = 10
    End If 
End Sub
Microsoft.VisualBasic.PowerPacks.ShapeContainer canvas = 
    new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
Microsoft.VisualBasic.PowerPacks.LineShape line1 = 
    new Microsoft.VisualBasic.PowerPacks.LineShape(10, 10, 200, 10);
private void LineDirection_Load(System.Object sender, System.EventArgs e)
{
    // Set the form as the parent of the ShapeContainer.
    canvas.Parent = this;
    // Set the ShapeContainer as the parent of the LineShape.
    line1.Parent = canvas;
}
private void LineDirection_Click(object sender, System.EventArgs e)
{
    ChangeDirection();
}
private void ChangeDirection()
{
    if (line1.X1 == line1.Y2)
    {
        line1.X2 = 10;
        line1.Y2 = 200;
    }
    else
    {
        line1.X2 = 200;
        line1.Y2 = 10;
    }
}

.NET Framework Security

See Also

Reference

LineShape Class

Microsoft.VisualBasic.PowerPacks Namespace

ShapeContainer

Shape

Other Resources

How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

How to: Draw Lines with the LineShape Control (Visual Studio)

Introduction to the Line and Shape Controls (Visual Studio)