Search Tools Links Login

Full example of Drag and Drop within a application

Posted: 2002-06-01
By: ArchiveBot
Viewed: 66

Filed Under:

VB6 Code Cache

No attachments for this post


Suppose you have a listbox with some elements and want to drag&drop a selected one into a textbox. http://137.56.41.168:2080/VisualBasicSource/vbdraganddrop.txt

Original Author: Found on the World Wide Web

Code

Make a form with a textbox (text1) and a listbox (list1). Fill the listbox with some items...
Make a label (label1). Set it invisible = False
Put the next code at the appropiate places:
Sub List1_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  Dim DY
  DY = TextHeight("A")
  Label1.Move list1.Left, list1.Top + Y - DY / 2, list1.Width, DY
  Label1.Drag
End Sub
Sub List1_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  If State = 0 Then Source.MousePointer = 12
  If State = 1 Then Source.MousePointer = 0
End Sub
Sub Form_DragOver (Source As Control, X As Single, Y As Single, State As Integer)
  If State = 0 Then Source.MousePointer = 12
  If State = 1 Then Source.MousePointer = 0
End Sub
Sub Text1_DragDrop (Index As Integer, Source As Control, X As Single, Y As Single)
  text1.text = list1
  
End Sub


Comments on this post

No comments have been added for this post.

You must be logged in to make a comment.