LineShape 类
更新:2007 年 11 月
表示显示为横线、竖线或对角线的控件。
命名空间: Microsoft.VisualBasic.PowerPacks
程序集: Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)
语法
声明
<ToolboxBitmapAttribute(GetType(LineShape), "Microsoft.VisualBasic.PowerPacks.LineShape.bmp")> _
Public Class LineShape _
Inherits Shape
用法
Dim instance As LineShape
[ToolboxBitmapAttribute(typeof(LineShape), "Microsoft.VisualBasic.PowerPacks.LineShape.bmp")]
public class LineShape : Shape
[ToolboxBitmapAttribute(typeof(LineShape), L"Microsoft.VisualBasic.PowerPacks.LineShape.bmp")]
public ref class LineShape : public Shape
public class LineShape extends Shape
备注
使用 LineShape 控件可在设计时或运行时在窗体或容器上绘制直线。
将 Line 或 Shape 控件添加到窗体或容器上后,将随即创建一个不可见的 ShapeContainer 对象。ShapeContainer 充当每个容器控件中各个形状的绘图图面;每个 ShapeContainer 均有一个对应的 ShapeCollection,使您可以循环访问 Line 和 Shape 控件。
在运行时创建 LineShape 控件时,还必须创建一个 ShapeContainer 并将 LineShape 的 Parent 属性设置为 ShapeContainer。
示例
下面的示例将创建一个 ShapeContainer 和一个 LineShape,将它们添加到窗体中,并从窗体顶部到底部显示一条竖线。
Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Dim line1 As New Microsoft.VisualBasic.PowerPacks.LineShape
' Set the form as the parent of the ShapeContainer.
canvas.Parent = Me
' Set the ShapeContainer as the parent of the LineShape.
line1.Parent = canvas
' Set the starting and ending coordinates for the line.
line1.StartPoint = New System.Drawing.Point(Me.Width / 2, 0)
line1.EndPoint = New System.Drawing.Point(Me.Width / 2, Me.Height)
Microsoft.VisualBasic.PowerPacks.ShapeContainer canvas =
new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
Microsoft.VisualBasic.PowerPacks.LineShape line1 =
new Microsoft.VisualBasic.PowerPacks.LineShape();
// Set the form as the parent of the ShapeContainer.
canvas.Parent = this;
// Set the ShapeContainer as the parent of the LineShape.
line1.Parent = canvas;
// Set the starting and ending coordinates for the line.
line1.StartPoint = new System.Drawing.Point(this.Width / 2, 0);
line1.EndPoint = new System.Drawing.Point(this.Width / 2, this.Height);
继承层次结构
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
Microsoft.VisualBasic.PowerPacks.Shape
Microsoft.VisualBasic.PowerPacks.LineShape
线程安全
此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。
另请参见
参考
Microsoft.VisualBasic.PowerPacks 命名空间
其他资源
如何:使用 OvalShape 和 RectangleShape 控件绘制形状 (Visual Studio)