drag n drop problem 
Author Message
 drag n drop problem

I copied the code from the .Net help and was able to create a drag n drop
routine from a listbox to a textbox using the mousedown event.  However,
when I try a second drag, the listbox keeps the same selected item that was
picked the first time, no matter which item I pick in the listbox.  Is there
a way around this?  Thanks in advance!

  Public Sub listbox1_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
    ListBox1.DoDragDrop(listbox1.selecteditem, DragDropEffects.Copy)
    End Sub

    Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles TextBox1.DragEnter
        If (e.Data.GetDataPresent(DataFormats.Text)) Then
            e.Effect = DragDropEffects.Copy
        Else
            e.Effect = DragDropEffects.None
        End If
    End Sub

Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles TextBox1.DragDrop
        TextBox1.Text = e.Data.GetData(DataFormats.Text).ToString
    End Sub



Thu, 17 Nov 2005 02:59:31 GMT  
 drag n drop problem
Damon,

Change your Mouse Down Event:
---
    Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As _
        System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown

        ListBox1.DoDragDrop(ListBox1.Items.Item(ListBox1.SelectedIndex),
DragDropEffects.Copy)

    End Sub
---

Vince


Quote:
> I copied the code from the .Net help and was able to create a drag n drop
> routine from a listbox to a textbox using the mousedown event.  However,
> when I try a second drag, the listbox keeps the same selected item that
was
> picked the first time, no matter which item I pick in the listbox.  Is
there
> a way around this?  Thanks in advance!

>   Public Sub listbox1_MouseDown(ByVal sender As Object, ByVal e As
> System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
>     ListBox1.DoDragDrop(listbox1.selecteditem, DragDropEffects.Copy)
>     End Sub

>     Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As
> System.Windows.Forms.DragEventArgs) Handles TextBox1.DragEnter
>         If (e.Data.GetDataPresent(DataFormats.Text)) Then
>             e.Effect = DragDropEffects.Copy
>         Else
>             e.Effect = DragDropEffects.None
>         End If
>     End Sub

> Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As
> System.Windows.Forms.DragEventArgs) Handles TextBox1.DragDrop
>         TextBox1.Text = e.Data.GetData(DataFormats.Text).ToString
>     End Sub



Thu, 17 Nov 2005 10:22:57 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. drag and drop problem

2. Treeview and OLE Drag -n- Drop problem

3. Drag and Drop problem ?

4. Drag and drop problems

5. Drag and Drop Problem

6. Drag-and-drop problem

7. ListView Drag&Drop Problem

8. ListView Drag and Drop problem in icon view

9. TreeView Drag&Drop problems

10. Drag and Drop Problem

11. Drop and Drag Problem and Deployment Problem in VB 50 Enterprise

12. OLE DROP AND DRAG PROBLEM AND DEPLOYMENT PROBLEM

 

 
Powered by phpBB® Forum Software