共用方式為


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 控制項都可讓您在表單或容器 (Container) 上繪製線條。

當您將 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

執行緒安全

這個型別的任何 Public static (在 Visual Basic 中為 Shared) 成員都具備執行緒安全。並非所有的執行個體成員都是安全執行緒。

請參閱

參考

LineShape 成員

Microsoft.VisualBasic.PowerPacks 命名空間

ShapeContainer

Shape

其他資源

HOW TO:使用 OvalShape 和 RectangleShape 控制項繪製圖案 (Visual Studio)

HOW TO:使用 LineShape 控制項繪製線條 (Visual Studio)

Line 和 Shape 控制項簡介 (Visual Studio)