SimpleShape.DisplayRectangle Property


Gets the rectangle that represents the display area of the shape.

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

public Rectangle DisplayRectangle { get; }

Property Value

Type: System.Drawing.Rectangle

A Rectangle that represents the display area of the shape .

You can call the SetBounds method to change the DisplayRectangle property in a single operation.

The following example shows how to use the DisplayRectangle method to determine whether two shapes overlap. This example requires that you have two OvalShape controls named OvalShape1 and OvalShape2 on a form. For best results, position the controls so that they overlap.

private void ovalShape1_Click(System.Object sender, System.EventArgs e)
    // Get the DisplayRectangle for each OvalShape.
    Rectangle rect1 = ovalShape1.DisplayRectangle;
    Rectangle rect2 = ovalShape2.DisplayRectangle;
    // If the DisplayRectangles intersect, move OvalShape2.
    if (rect1.IntersectsWith(rect2))
        ovalShape2.SetBounds(rect1.Right, rect1.Bottom, rect2.Width, rect2.Height);
Return to top