1,451
社区成员
发帖
与我相关
我的任务
分享
Module Module1
Dim WithEvents Tb1 As New Label
Dim i As Integer
Public Sub creat1() '动态添加控件过程
Tb1.BorderStyle = BorderStyle.Fixed3D
Dim labelname As Boolean
labelname = printyl.ControlCollection.Equals(Tb1.Name, Tb1.Name)
If labelname = True Then
i = i + 1
Tb1.Location = New System.Drawing.Point(100 + i, 100 + i)
Tb1.Name = "ttss" + CStr(i)
Tb1.Text = "ttss" + CStr(i)
End If
Tb1.Size = New System.Drawing.Size(200, 100)
printyl.Controls.Add(Tb1)
End Sub
Dim ss As Boolean
Dim mov As Point
Private Sub Tb1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Tb1.MouseMove
If ss = True Then
Dim a, b As Integer
a = mov.X - e.X
b = mov.Y - e.Y
Tb1.Location = New Point(Tb1.Location.X - a, Tb1.Location.Y - b)
ElseIf ss = False Then
Tb1.Location = New Point(Tb1.Location.X, Tb1.Location.Y)
End If
End Sub
Private Sub Tb1_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Tb1.MouseDown
ss = True
mov = New Point(e.X, e.Y)
End Sub
Private Sub Tb1_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Tb1.MouseUp
ss = False
End Sub