共用方式為


SimpleShape.Location 屬性

取得或設定相對於圖形的容器左上角之圖形左上角的座標。

命名空間:  Microsoft.VisualBasic.PowerPacks
組件:  Microsoft.VisualBasic.PowerPacks.Vs (在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

語法

'宣告
<BrowsableAttribute(True)> _
Public Property Location As Point
[BrowsableAttribute(true)]
public Point Location { get; set; }
[BrowsableAttribute(true)]
public:
property Point Location {
    Point get ();
    void set (Point value);
}
[<BrowsableAttribute(true)>]
member Location : Point with get, set
function get Location () : Point 
function set Location (value : Point)

屬性值

類型:Point
Point表示相對於其容器的左上角圖形的左上角。

備註

因為Point類別是實值型別 (Structure中Visual Basic, struct Visual C# 中),它會傳回值。 這表示存取的屬性會傳回一份圖形的左上角點。 因此,調整x或y參數Point傳回從這個屬性將不會影響LeftRightTop,或Bottom圖案的屬性值。 若要調整這些屬性,會個別設定每個屬性值或設定Location使用新的屬性Point

範例

下列範例示範如何使用Location屬性設為移動OvalShape控制項。 此範例中您需要OvalShape名 OvalShape1 為表單上的控制項。

Private Sub OvalShape1_Click() Handles OvalShape1.Click
    ' Move the shape incrementally until it reaches the bottom  
    ' of the form. 
    If OvalShape1.Bottom < Me.ClientSize.Height - 50 Then 
        ' Move down 50 pixels.
        OvalShape1.Location = New Point(OvalShape1.Left, 
          OvalShape1.Top + 50)
    Else 
        ' Move back to the top.
        OvalShape1.Location = New Point(OvalShape1.Left, 0)
    End If 
End Sub
private void ovalShape1_Click(System.Object sender, System.EventArgs e)
{
    // Move the shape incrementally until it reaches the bottom  
    // of the form. 
    if (ovalShape1.Bottom < this.ClientSize.Height - 50)
    // Move down 50 pixels.
    {
        ovalShape1.Location = new Point(ovalShape1.Left, ovalShape1.Top + 50);
    }
    else
    {
        // Move back to the top.
        ovalShape1.Location = new Point(ovalShape1.Left, 0);
    }
}

.NET Framework 安全性

請參閱

參考

SimpleShape 類別

Microsoft.VisualBasic.PowerPacks 命名空間

其他資源

Line 和 Shape 控制項簡介 (Visual Studio)

如何:使用 LineShape 控制項繪製線條 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)