Link to home
Start Free TrialLog in
Avatar of jorgemgonzalez
jorgemgonzalezFlag for United States of America

asked on

Drag and drop inside TextBox

Hi experts!

Is it possible to select part of a text, drag it and drop it somewhere else along the paragraph or to a different one in the same text box?

If so, how can this be accomplished.

Thanks a lot in advance.
Avatar of deer22
deer22
Flag of United States of America image

You can do this with the richtextbox...here is a link showing how...

http://www.vbdotnetforums.com/editors/28119-drag-selected-text-text-box-drop-other-applications.html
Yes it is possible.  You need to use the DragDrop method and then identify the location the drop occured, remove the text from the original position and place it at the drop location.

Ady
Avatar of jorgemgonzalez

ASKER

Thanks experts for the fast reply.

Here's my problem: While by default the rich text boxes keep the selection intact on mouse down, the text boxes don't, and for me to use rich text boxes I'd have to remake a whole application where a lot of things go on on those text boxes, (2) and (Lazy me!) I'm trying to avoid that.

Now, according to afoot's proposal (Which in honesty I don't know how to implement) the result would be like moving the selected text, when I need to be able (also) to copy the selected text and drop it somewhere else in that text box or the other. (Piece of cake in rich text boxes, but then again, it would be a lot of work on a tight schedule)

I may be asking too much, but if there's a way of doing it, I'd really appreciate help on the matter as well as a good snippet.

Otherwise I will have to die on the shore of the rich text box realms. ;)

Thanks a million in advance.

Before I go and try to do this for you completely ;) here is another link that is close to what you're wanting.  Now this isn't the complete solution, but I think with a little trial and error you can get this to work like you want...

the link below will get you started and will drag and drop ALL the text from one textbox to another...you're probably going to have to mess around with some flags and setting the dragdrop property at the right time to get this to work...

http://msdn.microsoft.com/en-us/library/aa289508%28VS.71%29.aspx

ASKER CERTIFIED SOLUTION
Avatar of deer22
deer22
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yup, I also checked this one: http://www.emoreau.com/Entries/Articles/2004/02/Drag-and-Drop-in-VBNet.aspx but I still have a problem with the selection.
That did it! The rest I got.

Thanks a million! Whatever but remaking this baby! :)