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 with get
function get DisplayRectangle () : Rectangle
屬性值
類型:Rectangle
A Rectangle ,表示顯示區域的形狀。
備註
您可以呼叫SetBounds方法,以變更DisplayRectangle單一作業中的屬性。
範例
下列範例示範如何使用DisplayRectangle方法,以判斷是否有兩個圖形重疊。 這個範例需要您有兩個OvalShape名 OvalShape1 和 OvalShape2 為表單上的控制項。 為了獲得最佳結果,調整控制項的位置,讓它們重疊。
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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。
請參閱
參考
Microsoft.VisualBasic.PowerPacks 命名空間
其他資源
Line 和 Shape 控制項簡介 (Visual Studio)