LineShape.X1 属性

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

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

语法

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

属性值

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

备注

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

可以通过设置 StartPoint 属性来更改启动的坐标。

示例

下面的示例演示如何通过更改 X1、 Y1X2Y2 属性更改一行对角线方向。

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)