共用方式為


SimpleShape.SetBounds Method

Sets the bounds of the shape to the specified location and size.

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

Syntax

'宣告
Public Sub SetBounds ( _
    left As Integer, _
    top As Integer, _
    width As Integer, _
    height As Integer _
)
public void SetBounds(
    int left,
    int top,
    int width,
    int height
)
public:
void SetBounds(
    int left, 
    int top, 
    int width, 
    int height
)
member SetBounds : 
        left:int * 
        top:int * 
        width:int * 
        height:int -> unit 
public function SetBounds(
    left : int, 
    top : int, 
    width : int, 
    height : int
)

Parameters

  • width
    Type: System.Int32
    The new Width property value of the shape.
  • height
    Type: System.Int32
    The new Height property value of the shape.

Remarks

You can use the SetBounds method to change a shape's size and location in a single statement.

Examples

The following example shows how to use the SetBounds method to change the size and location of a shape. Specifically, the shape is moved to the upper-left corner of the form and changed to a square. This example requires that you have a RectangleShape control named RectangleShape1 on a form.

Private Sub RectangleShape1_Click() Handles RectangleShape1.Click
    ' Change the Bounds property.
    RectangleShape1.SetBounds(0, 0, 100, 100)
End Sub
private void rectangleShape1_Click(System.Object sender, System.EventArgs e)
{
    // Change the Bounds property.
    rectangleShape1.SetBounds(0, 0, 100, 100);
}

.NET Framework Security

See Also

Reference

SimpleShape Class

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)

and RectangleShape Controls