dragdrop
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts
Page 1 of 1
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
Last edited by Dummy1912 on Thu May 08, 2014 7:11 am, edited 4 times in total.
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
sorry #Shim
nice tut but i can't use it.
its for files only
nice tut but i can't use it.
its for files only

visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
Doesn't listbox have an automatic sort option?
I'm not entire sure what you're wanting to do :?
Something like this may help: http://stackoverflow.com/questions/2157 ... ally-in-vb
I'm not entire sure what you're wanting to do :?
Something like this may help: http://stackoverflow.com/questions/2157 ... ally-in-vb
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
#CodenStuff,
sorry buts not a listbox as listbox but a flowlayoutpanel
:lol: yea its confusing sorry ;)
we want to sort the custom controls
with the .name of the ID

thanks guys
sorry buts not a listbox as listbox but a flowlayoutpanel
:lol: yea its confusing sorry ;)
we want to sort the custom controls
with the .name of the ID
Code: Select all
has been solved Private Sub lblLabelTarget_DragDrop(ByVal sender As _
System.Object, ByVal e As _
System.Windows.Forms.DragEventArgs) Handles _
MyBase.DragDrop
Dim source As Control = CType(e.Data.GetData(GetType(ListControlItem)), Control)
Dim target As Control = Me.ListBox3.GetChildAtPoint(Me.ListBox3.PointToClient(New Point(e.X, e.Y)))
If target IsNot Nothing Then
Dim ix As Integer = Me.ListBox3.Controls.GetChildIndex(target)
Me.ListBox3.Controls.SetChildIndex(source, ix)
End If
End Sub

thanks guys
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
5 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023