Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DragDrop Question

Status
Not open for further replies.

culshaja

Programmer
Aug 10, 1999
705
GB
Hi,

I am currently writing an app using drag-drop. I am trying to make it work so that when you drag from A to B, what was in B is then switched to be dragged. All I can seem to do is have B replace A in its original location!

James :) James Culshaw
jculshaw@active-data-solutions.co.uk
 
Hi,

What about this:
------------------------------------------------------------
'Place 3 text boxes on a form (text1, text2, text3) and a label (label1)
'Paste this code into the form.
'Try to drag from text1 to text2

Option Explicit
Dim Draggin As String

Private Sub Form_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
' Change pointer to no drop.
If State = 0 Then Source.MousePointer = 12
' Use default mouse pointer.
If State = 1 Then Source.MousePointer = 0
End Sub

Private Sub Text1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim DY ' Declare variable.
DY = TextHeight("A") ' Get height of one line.
Label1.Move Text1.Left, Text1.Top + Y - DY / 2, Text1.Width, DY
Label1.Drag ' Drag label outline.
Draggin = Text1.Text
Text3.Text = "We're now draggin: " & Draggin
End Sub

Private Sub Text2_DragDrop(Source As Control, X As Single, Y As Single)
Draggin = Text2.Text
Text3.Text = "We're now draggin: " & Draggin
End Sub
------------------------------------------------------------

Is that what you were looking for?
Sunaj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top