I created a simple WinForm test application (I can supply the code on request) containing two RichTextBoxes, one set to read-only and both with EnableAutoDragDrop set true. I pre-load the read-only control with some text then run the application. Upon dragging some portion of text from the read-only control to the other one, the text is moved rather than copied. That is, it is deleted from the supposed read-only control, which should be immutable. Am I correct that it should be immutable? Or is there some setting involved in this that needs adjustment?
More generally, I would be appreciative of a reference that describes just when a drag-and-drop is supposed to copy vs. move. The only thing I could find was on page 476 of the Windows User Experience Interaction Guidelines (for Vista): "Dragging and dropping: Object is moved or copied to the drop target". I did a series of tests between .NET applications, Word, WordPad, Outlook, and Firefox and found that they are inconsistent on the choice of move or copy.
Read-only property only means that the end user cannot modify the richtextbox's content manually. But the content in the richtextbox can still be changed from codes or drag/drop operation. That is to say, it does not break the immutable rules.
Setting EnableAutoDragDrop property to true makes the application implements the drag/drop logic in default means. So when you drag text from one richtextbox to another, the DragDropEffects is Move instead of Copy. To achieve your objective, you do not need to modify any codes but just pressing Ctrl key when your drag/drop. The default implementation will do the drag/drop as Copy when Ctrl key is pressed.
If you want to use Copy effect when drag/drop even without Ctrl key, you should not set the EnableAutoDragDrop. You should listen to RichTextBox's MouseDown and MouseMove event and call DoDragDrop(data, allowedEffects)
Please let me know if this answers your question. And if you have any future questions or concerns, do let me know. Have a nice day!
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact email@example.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by msorens Thursday, August 13, 2009 7:20 PM