Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Drag&Drop from a textbox - but still want to select text with the mouse

Posted on 2014-11-28
5
Medium Priority
?
142 Views
Last Modified: 2014-12-01
I'd like to perform a drag&drop from a textbox to another textbox.
If I trap the MouseDown event and start the DoDragDrop then I can perform the drag&drop.
eg.
        private void textBox_Adress_MouseDown(object sender, MouseEventArgs e)
        {
            textBox_Adress.DoDragDrop(textBox_Adress.Text, DragDropEffects.Copy);
        }

Open in new window

Unfortunately this then cripples the ability to select text within the textbox for modifying the contents of the textbox.
So.  How is the simplest way to allow the mouse to select text inside the textbox for editing AND allow the mouse to start a drag&drop of the complete contents of the textbox?
0
Comment
Question by:AndyAinscow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 40471238
Andy,

I don't do much Windows Forms any more, but I wonder if you use the MouseMove event, checking the Left button, what affect that would have?
0
 
LVL 40
ID: 40471296
Bob is right, you should use the MouseDown event. Look at the examples in the Control.DoDragDrop page of the online help, and you will get all the information that you need to perform the operation, from creating the icon or bitmap that will be used during the drag up to the moment the user drop what he was dragging.
0
 
LVL 44

Author Comment

by:AndyAinscow
ID: 40471353
Hi Bob, that is what I was thinking as one backup plan (I've got a couple of others that are lower down the pecking order).  Check the mouse move and only start the DoDragDrop as the mouse leaves the text box (unless there is a specific event firing on the mouse leaving the control) providing the left button was down.

I asked just in case there was a simple way like:
txtBox.MagicSetting = MagicSettings.On;
and then everything would still work.  I like simple ways to do things.
0
 
LVL 44

Author Comment

by:AndyAinscow
ID: 40471359
There is a MouseLeave event.  I'll look at using that.
0
 
LVL 44

Author Closing Comment

by:AndyAinscow
ID: 40473193
The MouseLeave event didn't work as I hoped so I had to use the MouseMove in the end.   Turned out to be only a few lines of code
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

662 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