|
-
June 30th, 2008, 01:21 PM
#1
drag text from Datagridview to richtextbox
I am trying to drag from datagridview and drop in richtextbox.
Can anyone throw expertise on what is wrong with the following code?
Code:
public void dataGridView1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
DataGridView.HitTestInfo info = dataGridView1.HitTest(e.X, e.Y);
if (info.RowIndex >= 0)
{
DataRowView view = (DataRowView)
dataGridView1.Rows[info.RowIndex].DataBoundItem;
if (view != null)
dataGridView1.DoDragDrop(view, DragDropEffects.Copy);
}
}
}
public void richTextBox1_DragDrop(object sender, DragEventArgs e)
{
// Get Start Position to Drop the Text
int i = richTextBox1.SelectionStart;
String s = richTextBox1.Text.Substring(i);
richTextBox1.Text = richTextBox1.Text.Substring(0, i);
if (e.Data.GetDataPresent(typeof(System.String)))
{
richTextBox1.Text = richTextBox1.Text + (System.String)e.Data.GetData(typeof(System.String));
}
richTextBox1.Text = richTextBox1.Text + s;
}
Yes, Possible!!
-
July 1st, 2008, 02:40 PM
#2
Re: drag text from Datagridview to richtextbox
Ok, let me be more clear..
i have used MouseDrop event for datagridview, and dragdrop and dragenter events for richtextbox here.
The code works for draging text from Microsoft Wordpad. But it does not for the text i try to drag from the datagridView..
Is it a compatibility issue between richtextbox and datagridview??
Where the experts are ??
Yes, Possible!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|