Advertisement
2002C Custom Controls/ Forms/ Menus #8664

Full example of Drag and Drop within a application

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

AI

Yapay Zeka Özeti: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Kaynak Kod
original-source
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
Orijinal Yorumlar (3)
Wayback Machine'den kurtarıldı