مشاركة عبر


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 Property Location As Point
    Get
    Set
'الاستخدام
Dim instance As SimpleShape
Dim value As Point

value = instance.Location

instance.Location = value
[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)

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 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 Security

See Also

Reference

SimpleShape Class

SimpleShape Members

Microsoft.VisualBasic.PowerPacks Namespace

Other Resources

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)