SimpleShape.DisplayRectangle 属性

获取表示形状的显示区域的矩形。

命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
<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
function get DisplayRectangle () : Rectangle

属性值

类型:System.Drawing.Rectangle
表示形状的显示区域的 Rectangle

备注

可以调用 SetBounds 方法将单个操作的 DisplayRectangle 属性。

示例

下面的示例演示如何使用 DisplayRectangle 方法确定两个形状是否重叠。 此示例要求您具有名为 OvalShape1 和 OvalShape2 的两个 OvalShape 控件在窗体上。 为了获得最佳结果,请确保控件,因此重叠。

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 安全性

请参见

参考

SimpleShape 类

Microsoft.VisualBasic.PowerPacks 命名空间

其他资源

Line 和 Shape 控件简介 (Visual Studio)

如何:使用 LineShape 控件绘制直线 (Visual Studio)

如何:使用 OvalShape 和 RectangleShape 控件绘制形状 (Visual Studio)