By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 791 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

Drag and Drop Question...

P: n/a
Hi there,

This is the code that I am using to drag items from a list box and drop them
into a text box.
I'm not sure, but from what I know, each item on a list box is an object.
Let say I get a bunch of names display on a list box now, how do I get the
text of each item to drop that text into a text box?

Private Sub lstResult_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lstResult.MouseDown
If e.Button = MouseButtons.Left Then

'invoke the drag and drop operation

lstResult.DoDragDrop(lstResult.SelectedItem, DragDropEffects.Move Or
DragDropEffects.Copy)

End If

End Sub

Private Sub txtPatient_DragDrop(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles txtPatient.DragDrop

txtPatient.Text = e.Data.GetData(DataFormats.Text).ToString

' If the Ctrl key was not pressed, remove the source text to effect a

' drag-and-drop move.

If (e.KeyState And CtrlMask) <> CtrlMask Then

lstResult.SelectedItem = ""

End If

End Sub

Private Sub txtPatient_DragEnter(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles txtPatient.DragEnter

' Check to be sure that the drag content is the correct type for this

' control. If not, reject the drop.

If (e.Data.GetDataPresent(DataFormats.Text)) Then

' If the Ctrl key was pressed during the drag operation then perform

' a Copy. If not, perform a Move.

If (e.KeyState And CtrlMask) = CtrlMask Then

e.Effect = DragDropEffects.Copy

Else

e.Effect = DragDropEffects.Move

End If

Else

e.Effect = DragDropEffects.None

End If

End Sub

Somebody out there that can help me out here.

Thanks very much for your inputs on this one.

Manny
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
And I figured this one too.
Thanks.
Manny
"Manuel Canas" <mc*****@hotmail.com> wrote in message
news:e3uFc.41527$l6.1315@clgrps12...
Hi there,

This is the code that I am using to drag items from a list box and drop them into a text box.
I'm not sure, but from what I know, each item on a list box is an object.
Let say I get a bunch of names display on a list box now, how do I get the
text of each item to drop that text into a text box?

Private Sub lstResult_MouseDown(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles lstResult.MouseDown
If e.Button = MouseButtons.Left Then

'invoke the drag and drop operation

lstResult.DoDragDrop(lstResult.SelectedItem, DragDropEffects.Move Or
DragDropEffects.Copy)

End If

End Sub

Private Sub txtPatient_DragDrop(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles txtPatient.DragDrop

txtPatient.Text = e.Data.GetData(DataFormats.Text).ToString

' If the Ctrl key was not pressed, remove the source text to effect a

' drag-and-drop move.

If (e.KeyState And CtrlMask) <> CtrlMask Then

lstResult.SelectedItem = ""

End If

End Sub

Private Sub txtPatient_DragEnter(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles txtPatient.DragEnter

' Check to be sure that the drag content is the correct type for this

' control. If not, reject the drop.

If (e.Data.GetDataPresent(DataFormats.Text)) Then

' If the Ctrl key was pressed during the drag operation then perform

' a Copy. If not, perform a Move.

If (e.KeyState And CtrlMask) = CtrlMask Then

e.Effect = DragDropEffects.Copy

Else

e.Effect = DragDropEffects.Move

End If

Else

e.Effect = DragDropEffects.None

End If

End Sub

Somebody out there that can help me out here.

Thanks very much for your inputs on this one.

Manny

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.