且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在VB.NET WinForms中以编程方式添加LineShape

更新时间:2023-11-30 15:48:22

首先,导入powerpacks命名空间以使您可以访问控件:

First, import the powerpacks namespace to give you access to the control:

Imports Microsoft.VisualBasic.PowerPacks

然后您可以这样做:

Dim startx As Integer
Dim starty As Integer
Dim endx As Integer
Dim endy As Integer
Dim yourline As New LineShape(startx, starty, endx, endy)

其中startx = x起始位置,starty = y起始位置,endx =结束x位置,endy =结束y位置. 如果要将其放在画布中,只需:

Where startx = the x starting position, starty = the y starting position, endx = the ending x position and endy = the ending y position. If you want to put it into a canvas, simply:

Dim yourcanvas As ShapeContainer
canvas.Parent = formName
yourline.Parent = canvas

有关更多信息和API参考,请访问: http://msdn.microsoft.com/en-us/library/bb918067.aspx

For more information and an API reference, go to: http://msdn.microsoft.com/en-us/library/bb918067.aspx