OvalShape 类

更新:2007 年 11 月

表示一个显示为圆形或椭圆形的控件。

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

语法

声明
<ToolboxBitmapAttribute(GetType(OvalShape), "Microsoft.VisualBasic.PowerPacks.OvalShape.bmp")> _
Public Class OvalShape _
    Inherits SimpleShape
用法
Dim instance As OvalShape
[ToolboxBitmapAttribute(typeof(OvalShape), "Microsoft.VisualBasic.PowerPacks.OvalShape.bmp")]
public class OvalShape : SimpleShape
[ToolboxBitmapAttribute(typeof(OvalShape), L"Microsoft.VisualBasic.PowerPacks.OvalShape.bmp")]
public ref class OvalShape : public SimpleShape
public class OvalShape extends SimpleShape

备注

可以使用 OvalShape 控件在设计时或运行时在窗体或容器上绘制圆形和椭圆形。

将 Line 或 Shape 控件添加到窗体或容器上后,将随即创建一个不可见的 ShapeContainer 对象。ShapeContainer 充当每个容器控件内各个形状的绘制图面。每个 ShapeContainer 均有一个对应的 ShapeCollection,使您可以循环访问 ShapeContainer 中所包含的 Line 和 Shape 控件。

在运行时创建 OvalShape 控件时,还必须创建一个 ShapeContainer 并将 OvalShape 的 Parent 属性设置为 ShapeContainer

示例

下面的示例创建一个 ShapeContainer 和一个 OvalShape,将它们添加到窗体中,然后显示一个圆形。

Private Sub DrawCircle()
    Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
    Dim oval1 As New Microsoft.VisualBasic.PowerPacks.OvalShape
    ' Set the form as the parent of the ShapeContainer.
    canvas.Parent = Me
    ' Set the ShapeContainer as the parent of the OvalShape.
    oval1.Parent = canvas
    ' Set the location and size of the circle.
    oval1.Left = 10
    oval1.Top = 10
    oval1.Width = 100
    oval1.Height = 100
End Sub
private void DrawCircle1()
{
    Microsoft.VisualBasic.PowerPacks.ShapeContainer canvas = 
        new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
    Microsoft.VisualBasic.PowerPacks.OvalShape oval1 = 
        new Microsoft.VisualBasic.PowerPacks.OvalShape();
    // Set the form as the parent of the ShapeContainer.
    canvas.Parent = this;
    // Set the ShapeContainer as the parent of the OvalShape.
    oval1.Parent = canvas;
    // Set the location and size of the circle.
    oval1.Left = 10;
    oval1.Top = 10;
    oval1.Width = 100;
    oval1.Height = 100;
}

继承层次结构

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      Microsoft.VisualBasic.PowerPacks.Shape
        Microsoft.VisualBasic.PowerPacks.SimpleShape
          Microsoft.VisualBasic.PowerPacks.OvalShape

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

另请参见

参考

OvalShape 成员

Microsoft.VisualBasic.PowerPacks 命名空间

其他资源

Line 和 Shape 控件简介 (Visual Studio)

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

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