LineShape.X2 属性

获取或设置的 X 坐标 LineShape 控件绘制的终点行。

命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
<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)

属性值

类型:System.Int32
Integer 表示的 X (水平坐标) 终结点行。

备注

该坐标是相对 LineShape 控件的容器和使用像素表示。

可以通过设置 EndPoint 属性来更改关闭坐标。

示例

下面的示例演示如何通过更改 X1Y1、 X2和 Y2 属性更改一行对角线方向。

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 安全性

请参见

参考

LineShape 类

Microsoft.VisualBasic.PowerPacks 命名空间

ShapeContainer

Shape

其他资源

如何:使用 OvalShape 和 RectangleShape 控件绘制形状 (Visual Studio)

如何:使用 LineShape 控件绘制直线 (Visual Studio)

Line 和 Shape 控件简介 (Visual Studio)