RectangleShape 类
更新:2007 年 11 月
表示一个显示为正方形、矩形、圆角正方形或圆角矩形的控件。
命名空间: Microsoft.VisualBasic.PowerPacks
程序集: Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
语法
声明
<ToolboxBitmapAttribute(GetType(RectangleShape), "Microsoft.VisualBasic.PowerPacks.RectangleShape.bmp")> _
Public Class RectangleShape _
Inherits SimpleShape
用法
Dim instance As RectangleShape
[ToolboxBitmapAttribute(typeof(RectangleShape), "Microsoft.VisualBasic.PowerPacks.RectangleShape.bmp")]
public class RectangleShape : SimpleShape
[ToolboxBitmapAttribute(typeof(RectangleShape), L"Microsoft.VisualBasic.PowerPacks.RectangleShape.bmp")]
public ref class RectangleShape : public SimpleShape
public class RectangleShape extends SimpleShape
备注
可以使用 RectangleShape 控件在设计时或运行时在窗体或容器上绘制矩形。
将 Line 或 Shape 控件添加到窗体或容器上后,将随即创建一个不可见的 ShapeContainer 对象。ShapeContainer 充当每个容器控件内各个形状的绘制图面。每个 ShapeContainer 均有一个对应的 ShapeCollection,使您可以循环访问 ShapeContainer 中所包含的 Line 和 Shape 控件。
在运行时创建 RectangleShape 控件时,还必须创建一个 ShapeContainer 并将 RectangleShape 的 Parent 属性设置为 ShapeContainer。
示例
下面的示例创建一个 ShapeContainer 和一个 RectangleShape,将它们添加到窗体中,然后显示一个矩形。
Private Sub DrawRectangle()
Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Dim rect1 As New Microsoft.VisualBasic.PowerPacks.RectangleShape
' Set the form as the parent of the ShapeContainer.
canvas.Parent = Me
' Set the ShapeContainer as the parent of the RectangleShape.
rect1.Parent = canvas
' Set the location and size of the rectangle.
rect1.Left = 10
rect1.Top = 10
rect1.Width = 300
rect1.Height = 100
End Sub
private void DrawRectangle()
{
Microsoft.VisualBasic.PowerPacks.ShapeContainer canvas =
new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
Microsoft.VisualBasic.PowerPacks.RectangleShape rect1 =
new Microsoft.VisualBasic.PowerPacks.RectangleShape();
// Set the form as the parent of the ShapeContainer.
canvas.Parent = this;
// Set the ShapeContainer as the parent of the RectangleShape.
rect1.Parent = canvas;
// Set the location and size of the rectangle.
rect1.Left = 10;
rect1.Top = 10;
rect1.Width = 300;
rect1.Height = 100;
}
继承层次结构
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
Microsoft.VisualBasic.PowerPacks.Shape
Microsoft.VisualBasic.PowerPacks.SimpleShape
Microsoft.VisualBasic.PowerPacks.RectangleShape
线程安全
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
另请参见
参考
Microsoft.VisualBasic.PowerPacks 命名空间
其他资源
Line 和 Shape 控件简介 (Visual Studio)