dasm
June 30th, 2008, 01:21 PM
I am trying to drag from datagridview and drop in richtextbox.
Can anyone throw expertise on what is wrong with the following 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;
}
Can anyone throw expertise on what is wrong with the following 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;
}