Solved

Drag and drop inside TextBox

Posted on 2010-11-23
8
450 Views
Last Modified: 2012-05-10
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.
0
Comment
Question by:jorgemgonzalez
  • 4
  • 3
8 Comments
 
LVL 3

Expert Comment

by:deer22
ID: 34197599
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
0
 
LVL 16

Expert Comment

by:Ady Foot
ID: 34197602
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
0
 
LVL 3

Expert Comment

by:deer22
ID: 34197615
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

Author Comment

by:jorgemgonzalez
ID: 34198262
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.

0
 
LVL 3

Expert Comment

by:deer22
ID: 34199110
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

0
 
LVL 3

Accepted Solution

by:
deer22 earned 500 total points
ID: 34199378
Alright well I'm going to get you a little further...

I attached some code which will drag the selected text from textbox1 to either textbox1 or textbox2.  Once dropped the textbox will contain the selected text.  Now to add it in the right place or where the mouse is positioned without losing the textboxes content before the drop will require more work...

Get the mouse position
Append the text to where the mouse is positioned

If you still can't get it working let me know...
tmp.txt
0
 

Author Comment

by:jorgemgonzalez
ID: 34199610
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.
0
 

Author Closing Comment

by:jorgemgonzalez
ID: 34199811
That did it! The rest I got.

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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error handling in asp.net site 5 34
export data table to excel in vb.net 10 36
Sql server, import complete table, using vb.net 9 43
location of a form 2 25
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question