VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Full example of Drag and Drop within a application

by Found on the World Wide Web (15 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (42 Votes)

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

Rate Full example of Drag and Drop within a application

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

Download this snippet    Add to My Saved Code

Full example of Drag and Drop within a application Comments

No comments have been posted about Full example of Drag and Drop within a application. Why not be the first to post a comment about Full example of Drag and Drop within a application.

Post your comment

Subject:
Message:
0/1000 characters