共用方式為


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)

屬性值

類型:Int32
Integer 表示線條的起始點的 X (水平) 座標。

備註

座標是相對於容器的LineShape控制項,並以像素為單位。

您也可以藉由設定變更的起始座標StartPoint屬性。

範例

下列範例示範如何藉由變更變更的對角線方向X1, Y1X2,和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)