Compartilhar via


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)

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property DisplayRectangle As Rectangle
[BrowsableAttribute(false)]
public Rectangle DisplayRectangle { get; }
[BrowsableAttribute(false)]
public:
property Rectangle DisplayRectangle {
    Rectangle get ();
}
[<BrowsableAttribute(false)>]
member DisplayRectangle : Rectangle with get
function get DisplayRectangle () : Rectangle

Property Value

Type: System.Drawing.Rectangle
A Rectangle that represents the display area of the shape .

Remarks

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

Examples

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 Sub OvalShape1_Click() Handles OvalShape1.Click
    ' Get the DisplayRectangle for each OvalShape. 
    Dim rect1 As Rectangle = OvalShape1.DisplayRectangle
    Dim rect2 As Rectangle = OvalShape2.DisplayRectangle
    ' If the DisplayRectangles intersect, move OvalShape2. 
    If rect1.IntersectsWith(rect2) Then
        OvalShape2.SetBounds(rect1.Right, rect1.Bottom, 
          rect2.Width, rect2.Height)
    End If 
End Sub
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);
    }
}

.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)