Swapping text between textboxes using drag'n'drop?

tonyrb

New member
Joined
Oct 1, 2006
Messages
2
Programming Experience
1-3
Hi all,

First time posting here.

I need some help with implementing this functionality in VB 2005. I was able to do this in Visual Basic 6, but in VB 2005 Express I am having a hard time with drag'n'drop.

How do I get two textboxes to swap text? All the examples I have found are only to either copy or move text from one textbox to another not swap the text.

I have drag'n'drop working...I can move or copy text from one textbox to another, but I want to be able to select some text in one textbox and drag it over to another textbox and have the text swap when I drop the text onto the drop target.

Thank you very much for your help!

Tony
 
Ok, you know how to do drag and drop. Good, it's a basic operation. Now try first to do the swap without drag and drop. Set the HideSelection property to False for both textboxes so you can select text in both control without missing the selection when a textbox loose focus. Add a button and in its click event try to do the swap for text selected in both controls. You should be able to do this in three lines of code. It's the same that must happen when you put this into a dragdrop operation, same three lines of code basically.

I must add that starting a drag operation on selected text is really difficult for user since almost any way user tries to click and drag text only result in de-selection or re-selection. My suggestion with a 'swap' button is much easier and better UI.
 
Thanks!

I agree (now that I step back from the problem) that a swap button would probably be better. The program I had this working on in VB6 used label controls instead of textboxes. I was trying to replicate the same functionality in the new program in VB2005 but using textboxes.

Thank you very much,

Tony
 
Back
Top