dragdrop
Posted: Wed May 07, 2014 2:24 pm
hello,
searching the net and drives me nuts :lol:
do any one know how i can manage the dragdrop effect
this is what we have for now.
what i want to as result is
we have no. like 1,2,3,4,5,6,7,8 ect...
and i have no. like 5,2,3,4,1
so when we wanna change a control his no.
we want to drag it to a other place
for example we are gonna relocate no.5 to end no.4
how can we make it so it do it all automatic
it will order them in correct way even what number you are dragging to a other place
so it will be always
1
2
3
4
5
ect....
hope someone will help soon
thanks
searching the net and drives me nuts :lol:
do any one know how i can manage the dragdrop effect
Code: Select all
Dim c As New ListControlItem
With c
.Name = "item" & IntID 'this does keep the 1,2,3,4,5 ect..
'because in the database we have AUTOINCREMENT
End With
AddHandler Control.MouseDown, AddressOf startDrag
AddHandler Control.MouseMove, AddressOf whileDragging
AddHandler Control.MouseUp, AddressOf endDrag
ListBox3.Controls.Add(c)'flowlayoutpanel
Code: Select all
Private Sub startDrag(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs)
dragging = True
startX = e.X
startY = e.Y
End Sub
Private Sub whileDragging(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.MouseEventArgs)
If dragging = True Then
sender.Location = New Point(sender.Location.X + _
e.X - startX, sender.Location.Y + e.Y - startY)
Me.Refresh()
End If
End Sub
Private Sub endDrag(ByVal sender As System.Object, ByVal e As System.EventArgs)
dragging = False
End Sub
Code: Select all
'does nothing ?? Private Sub lblLabelTarget_DragDrop(ByVal sender As _
System.Object, ByVal e As _
System.Windows.Forms.DragEventArgs) Handles _
MyBase.DragDrop
If e.Data.GetData(GetType(ListControlItem)) IsNot Nothing Then
Dim myIndex As Integer = Me.ListBox3.Controls.GetChildIndex(CType(e.Data.GetData(GetType(ListControlItem)), ListControlItem))
Dim element As ListControlItem = CType(e.Data.GetData(GetType(ListControlItem)), ListControlItem)
Me.ListBox3.Controls.SetChildIndex(element, myIndex)
End If
End Sub
this is what we have for now.
what i want to as result is
we have no. like 1,2,3,4,5,6,7,8 ect...
and i have no. like 5,2,3,4,1
so when we wanna change a control his no.
we want to drag it to a other place
for example we are gonna relocate no.5 to end no.4
how can we make it so it do it all automatic
it will order them in correct way even what number you are dragging to a other place
so it will be always
1
2
3
4
5
ect....
hope someone will help soon

thanks