1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| Imports System
Public Class Form1
Dim Cliquex, cliquey, posx, posy As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim groubox As groubox
groupbox = New GroupBox
groupbox.AllowDrop = True
groupbox.AccessibleDescription = "False"
groupbox.Location = New System.Drawing.Point(i * 70 + 30, 30)
groupbox.Size = New System.Drawing.Point(50, 50)
groupbox.Text = "Matricule N°" + CStr(i)
AddHandler groupbox.MouseDown, AddressOf f1
AddHandler groupbox.MouseMove, AddressOf f2
AddHandler groupbox.MouseUp, AddressOf f3
Me.Controls.Add(groupbox)
groupbox.BringToFront()
End Sub
Private Sub f1(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If e.Button = Windows.Forms.MouseButtons.Left Then
sender.accessibledescription = "True"
posx = sender.location.x
posy = sender.location.y
Cliquex = e.X
cliquey = e.Y
Else
MsgBox("Bouton droit enfoncé!!!")
End If
End Sub
Private Sub f2(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
If (sender.accessibledescription = "True") Then
Me.Cursor = Cursors.NoMove2D
sender.Location = New System.Drawing.Point(sender.Left + e.X - Cliquex, sender.Top + e.Y - cliquey)
sender.bringtofront()
End If
End Sub
Private Sub f3(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
sender.accessibledescription = "False"
sender.bringtofront()
Me.Cursor = Cursors.Default
End Sub
End Class |
Partager