Propriedade LineShape.X2

Obtém ou define a coordenada x do ponto final de uma linha desenhada por um LineShape controle.

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

Sintaxe

'Declaração
<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)

Valor de propriedade

Tipo: System.Int32
Um Integer que representa a coordenada de X (horizontal) do ponto final da linha.

Comentários

A coordenada é relativo ao contêiner da LineShape de controle e é expresso em pixels.

Você também pode alterar as coordenadas final, definindo a EndPoint propriedade.

Exemplos

O exemplo a seguir demonstra como alterar a direção de uma linha diagonal, alterando a X1, Y1, X2, e Y2 propriedades.

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;
    }
}

Segurança do .NET Framework

Consulte também

Referência

LineShape Classe

Namespace Microsoft.VisualBasic.PowerPacks

ShapeContainer

Shape

Outros recursos

Como: desenhar formas com os controles de RectangleShape (Visual Studio) e o OvalShape

Como: desenhar linhas com o controle de LineShape (Visual Studio)

Introdução à linha e controles Shape (Visual Studio)