Share via


SimpleShape.Location Property

 

Gets or sets the coordinates of the upper-left corner of the shape relative to the upper-left corner of its container.

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

Syntax

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

Property Value

Type: System.Drawing.Point

The Point that represents the upper-left corner of the shape relative to the upper-left corner of its container.

Remarks

Because the Point class is a value type (Structure in Visual Basic, struct in Visual C#), it is returned by value. This means that accessing the property returns a copy of the upper-left point of the shape. Therefore, adjusting the x or y parameters of the Point returned from this property will not affect the Left, Right, Top, or Bottom property values of the shape. To adjust these properties, set each property value individually, or set the Location property by using a new Point.

Examples

The following example demonstrates how to use the Location property to move an OvalShape control. This example requires that you have an OvalShape control named OvalShape1 on a form.

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

See Also

SimpleShape Class
Microsoft.VisualBasic.PowerPacks Namespace
Introduction to the Line and Shape Controls (Visual Studio)
How to: Draw Lines with the LineShape Control (Visual Studio)
How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

Return to top