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(ByVal sender As System.Object, ByVal e As
System.EventArgs) 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.AllowDrop = True
End Sub
Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
If (ListBox1.Items.Count > 0) Then
Dim index As Integer = ListBox1.IndexFromPoint(e.X, e.Y)
Dim strElementOrigin As String = ListBox1.Items(index).ToString()
Dim dde As DragDropEffects = DoDragDrop(strElementOrigin,
DragDropEffects.All)
If dde = DragDropEffects.All Then
ListBox1.Items.RemoveAt(ListBox1.IndexFromPoint(e. X, e.Y))
End If
End If
End Sub
Private Sub ListBox2_DragOver(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles ListBox2.DragOver
e.Effect = DragDropEffects.All
End Sub
Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
If e.Data.GetDataPresent(DataFormats.StringFormat) Then
Dim strElementDestiny As String =
e.Data.GetData(DataFormats.StringFormat).ToString( )
ListBox2.Items.Add(strElementDestiny)
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*******************@NOQUIEROSPAMportalvbNOSPAM. com.NOQUIEROSPAM>
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,