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.
5 posts Page 1 of 1
Contributors
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

dragdrop
Dummy1912
hello,

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
    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

'does nothing ??

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
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: dragdrop
Shim
See if this helps http://tinyurl.com/mbmkzar
Find my programs on Softpedia
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: dragdrop
Dummy1912
sorry #Shim
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
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Re: dragdrop
CodenStuff
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
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: dragdrop
Dummy1912
#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

Code: Select all
    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

has been solved :D
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
5 posts Page 1 of 1
Return to “Coding Help & Support”