Results 1 to 2 of 2

Thread: Drag & Drop [RESOLVED]

Threaded View

  1. #1

    Thread Starter
    Fanatic Member Geespot's Avatar
    Join Date
    Oct 2001
    Location
    Birmingham, UK
    Posts
    577

    Drag & Drop [RESOLVED]

    Hiya,

    I have a listbox that contains a list of filename. What I need to do is drag a text item from the listbox, and drop it onto a label. Then the label's Text property changes to the filename that was dragged onto it.

    I can do that.

    but if I drag a different filename from the listbox, and drop it onto the label. Nothing happens. But if I change listboxs index using the cursor keys, and then drag, it works.

    Why does it do this? Im thinking the listbox is still in a drag state after I drop the item onto the label, and pressing a key interupts that state. Although I am probably wrong. I just don't understand what is happeneing.

    This is the code that im using

    VB Code:
    1. Private Sub lstBeats_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lstBeats.MouseDown
    2.         If e.Button = MouseButtons.Left Then
    3.             If Not lstBeats.SelectedItem Is Nothing Then
    4.                 lstBeats.DoDragDrop(lstBeats.SelectedItem.ToString, DragDropEffects.Copy)
    5.             End If
    6.         End If
    7.     End Sub
    8.  
    9.  
    10.     Private Sub lblBeat_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lblBeat.DragEnter
    11.         If e.Data.GetDataPresent(DataFormats.Text) Then
    12.             e.Effect = DragDropEffects.Copy
    13.         End If
    14.     End Sub
    15.  
    16.     Private Sub lblBeat_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles lblBeat.DragDrop
    17.         lblBeat.Text = (e.Data.GetData(DataFormats.StringFormat, False).ToString)
    18.     End Sub
    Last edited by Geespot; Sep 8th, 2003 at 01:15 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width