Ok.
I hope that the next sample of code helps you to understand how can you use
the drag & drop feature in VB.NET. :-)
Regards.
Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
ListBox1.Items. Add("ListBox1 - Ele 1")
ListBox1.Items. Add("ListBox1 - Ele 2")
ListBox1.Items. Add("ListBox1 - Ele 3")
ListBox1.Items. Add("ListBox1 - Ele 4")
ListBox2.Items. Add("ListBox2 - Ele 1")
ListBox2.Items. Add("ListBox2 - Ele 2")
ListBox2.Items. Add("ListBox2 - Ele 3")
ListBox2.AllowD rop = True
End Sub
Private Sub ListBox1_MouseD own(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListBox1.MouseD own
If (ListBox1.Items .Count > 0) Then
Dim index As Integer = ListBox1.IndexF romPoint(e.X, e.Y)
Dim strElementOrigi n As String = ListBox1.Items( index).ToString ()
Dim dde As DragDropEffects = DoDragDrop(strE lementOrigin,
DragDropEffects .All)
If dde = DragDropEffects .All Then
ListBox1.Items. RemoveAt(ListBo x1.IndexFromPoi nt(e.X, e.Y))
End If
End If
End Sub
Private Sub ListBox2_DragOv er(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles ListBox2.DragOv er
e.Effect = DragDropEffects .All
End Sub
Private Sub ListBox2_DragDr op(ByVal sender As Object, ByVal e As
System.Windows. Forms.DragEvent Args) Handles ListBox2.DragDr op
If e.Data.GetDataP resent(DataForm ats.StringForma t) Then
Dim strElementDesti ny As String =
e.Data.GetData( DataFormats.Str ingFormat).ToSt ring()
ListBox2.Items. Add(strElementD estiny)
End If
End Sub
--
Jorge Serrano Pérez
Microsoft MVP VB.NET
PortalVB.com
http://www.portalvb.com/
Weblog de Jorge Serrano
http://weblogs.golemproject.com/jorge/
"JL" wrote:
Thank you Jorge for the response. I did find that article when I ran
Google. And I understand doing drag/drop between controls but not
within a single ListBox so my user can re-order the items in the list.
John
On Sun, 13 Nov 2005 04:36:04 -0800, "Jorge Serrano [MVP VB]"
<NO************ *******@NOQUIER OSPAMportalvbNO SPAM.com.NOQUIE ROSPAM>
wrote:
Hi,
I think that you'll find useful information about Drag & Drop in the next URL:
http://www.vb-helper.com/howto_net_d...op_object.html
I hope that helps.
Best regards,