Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2004

Tip: Looking for answers? Try searching our database.

Drag drop in RichTextBox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jerry - 08 Dec 2004 09:42 GMT
Hi,

   I find some strange thing when I use drag drop in RichTextBox control. I
create a control inherit RichTextBox.:

   1. In OnDragEnter and OnDragOver, AllowDragDropEffect of DragEventArgs
is DragDropEffects.All always.
   2. I can't find where I can set the DragDropEffect when I do drag drop
in RichTextBox.

   Who can help me? thanks.

Jerry
Lance Johnson - 08 Dec 2004 15:24 GMT
This appears to be the tricky part.  For some reason, they have neglected to
implement the code for dragging items from a richtextbox.  I've been working
on this recently but am not entirely sure this is accurate.  Maybe somebody
can help us out on this.  To begin with, there's a certain dragsize that has
to occur before a drag operation.  You can find that in
SystemInformation.DragSize.

1) Override the mousedown method and if mouse is over selected text set a
variable to know the rectangle area to not be considered a drag operation.
To do this, get the index by GetCharIndexFromPosition and then see if it's
in the range of selection.  Make sure something is selected first.
2) Override the mousemove method and if the left mouse is down and the
dragging area is not empty and the current position is outside of the
rectangle area set from mousedown, you can begin a drag operation.  Look at
the method DoDragDrop.  Upon return from this, I'd reset the rectangle area
to empty.

Hope this helps some and I hope I'm on the right track also.

Lance Johnson

> Hi,
>
[quoted text clipped - 10 lines]
>
> Jerry
Jerry - 09 Dec 2004 01:54 GMT
Thank you for your answer. I have realized the drag drop by a simple method:
just
override OnDragEnter, OnDragOver and OnDragDrop. But I can't get the effect
I expect:
Drag effect is Copy when I drag a item from another control(for example,
from a TreeView),
Because the AllowDragDropEffect that I get in OnDragEnter and OnDragOver is
DragDropEffects.All always. I can't sure the drag operation is from another
control or itself.
Do you have an ideal about it? Thank again.

Jerry

> This appears to be the tricky part.  For some reason, they have neglected to
> implement the code for dragging items from a richtextbox.  I've been working
[quoted text clipped - 31 lines]
> >
> > Jerry

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.