S
Sarah Marriott
Hi all,
I hope this is the correct forum for my VB.NET forms based question.
I have written an application which uses my own user controls which the user
can position dynamically on a form.
The user control has several standard controls on it (labels/comboboxes etc)
but there is space at the top allowing the user to click on the control
itself.
The code I use at the moment to allow the user to move the control is fairly
simple:
Private Sub DataSource_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
If State = WAITING Then
State = DRAGGING
Pic_X = e.X 'Pic_X and Pic_Y are declared on the form
Pic_Y = e.Y
End If
End Sub
Private Sub DataSource_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
If State = DRAGGING Then
If TypeOf sender Is ctl_Datasource Then
Dim mox As Integer
Dim moy As Integer
mox = e.X - Pic_X
moy = e.Y - Pic_Y
sender.Top = sender.top + moy
sender.Left = sender.Left + mox
End If
End If
End Sub
Private Sub DataSource_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
State = WAITING
End Sub
The controls (of which there can be over 20 on the form at any one time) are
generated dynamically when the form loads and moved into position based on
their last known position, which was stored in a database when the form was
last closed.
My main problem is that I would like the user to be able to 'drag select'
several controls and move them simultaneously. Something similar to
selecting and dragging several things around on the desktop together.This
would make organising the form so much easier!
Can anyone give me any pointers?
TIA
Sarah
I hope this is the correct forum for my VB.NET forms based question.
I have written an application which uses my own user controls which the user
can position dynamically on a form.
The user control has several standard controls on it (labels/comboboxes etc)
but there is space at the top allowing the user to click on the control
itself.
The code I use at the moment to allow the user to move the control is fairly
simple:
Private Sub DataSource_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
If State = WAITING Then
State = DRAGGING
Pic_X = e.X 'Pic_X and Pic_Y are declared on the form
Pic_Y = e.Y
End If
End Sub
Private Sub DataSource_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
If State = DRAGGING Then
If TypeOf sender Is ctl_Datasource Then
Dim mox As Integer
Dim moy As Integer
mox = e.X - Pic_X
moy = e.Y - Pic_Y
sender.Top = sender.top + moy
sender.Left = sender.Left + mox
End If
End If
End Sub
Private Sub DataSource_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs)
State = WAITING
End Sub
The controls (of which there can be over 20 on the form at any one time) are
generated dynamically when the form loads and moved into position based on
their last known position, which was stored in a database when the form was
last closed.
My main problem is that I would like the user to be able to 'drag select'
several controls and move them simultaneously. Something similar to
selecting and dragging several things around on the desktop together.This
would make organising the form so much easier!
Can anyone give me any pointers?
TIA
Sarah