Hello,
thank you.
I have tried the following sample from msdn (dot net 1.1 !).
private void TestPanel_Load(object sender, System.EventArgs e)
{
richTextBox1.DragEnter += new DragEventHandler(richTextBox1_DragEnter);
richTextBox1.DragDrop += new DragEventHandler(richTextBox1_DragDrop);
}
private void richTextBox1_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Text))
e.Effect = DragDropEffects.Copy ;
else
e.Effect = DragDropEffects.None ;
}
private void richTextBox1_DragDrop(object sender, DragEventArgs e)
{
int i;
String s;
// Get start position to drop the text.
i = richTextBox1.SelectionStart;
s = richTextBox1.Text.Substring(i);
richTextBox1.Text = richTextBox1.Text.Substring(0,i);
// Drop the text on to the RichTextBox.
richTextBox1.Text = richTextBox1.Text +
e.Data.GetData(DataFormats.Text).ToString();
richTextBox1.Text = richTextBox1.Text + s;
}
It's very simple, but does not work.
If you drag from another richtextbox on this with this implementation,
you see the DragDropEffects.non cursor and the text is not dropped.
On the otther hand in the richtextbox which is the dragdrop source
nonsence take place, the selection disappears, the caret goes to the start
of the line.
Seems, that in msdn are samples, which nobody ever has realy run.
Thank you.
Rolf
> Hi Rolf,
>
[quoted text clipped - 40 lines]
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
Linda Liu [MSFT] - 02 Aug 2006 11:20 GMT
Hi Rolf,
Do you mean that you could compile the sample project successfully and run
it? If yes, it's sure that there's no compilation error in the project.
Since the sample code only handles the DropEnter and DropDrop events of
richTextBox1, you should test this program by dragging some text from other
sources and drop it onto the richTextBox1. For example, you could use
WordPad as a drag&drop source.
To open Wordpad, go to Start menu and select Run. In the textbox of Run
window, type "wordpad" and press Enter. Thus, Workpad is opened. You may
type some text in the Wordpad, and drag&drop the text onto the richTextBox1
when the program is running.
Please try my suggestion and see if the drag&drop operation work when you
use Wordpad as the source.
Sincerely,
Linda Liu
Microsoft Online Community Support
Rolf Welskes - 03 Aug 2006 21:18 GMT
Hello,
you are right,
from word pad to the implemented richtextbox I can drag a text. oK.
BUT
I need only the way to drag from an own richtextbox to another own
richtextbox.
Is this not possible.
Thank you.
Rolf
> Hi Rolf,
>
[quoted text clipped - 19 lines]
> Linda Liu
> Microsoft Online Community Support
Linda Liu [MSFT] - 04 Aug 2006 10:24 GMT
Hi Rolf,
You could handle the RichTextBox's MouseMove event and call the DoDragDrop
method of the RichTextBox in this event handler.
Below is a sample.
private void richTextBox1_MouseMove(object sender,
System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.richTextBox1.DoDragDrop(this.richTextBox1.Text,DragDropEffects.Copy);
}
}
Thus, you could drag the text in the richTextBox1 and drop it onto other
richTextBox whose DragEnter and DragDrop events have been handled.
Hope this helps.
If you have anything unclear, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support
Linda Liu [MSFT] - 08 Aug 2006 08:28 GMT
Hello Rolf,
I am closely monitoring the newsgroup and I am contacting you to check the
issue status.
If the problem is not resolved or you have anything unclear, please feel
free to post in the newsgroup and we will follow up.
Thank you for using our MSDN Managed Newsgroup Support Service!
Sincerely,
Linda Liu
Microsoft Online Community Support