i have verry good results, but there is something that seems not to work. I have dataGridView1 from witch i want to drag data and drop to dataGridView2. Looks Ok for dataGridView1, but when i tryed to drop data to dataGridView2 the content is not send. where am I wrong?
CODE
private void dataGridView2_DragDrop(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(typeof(System.String)))
{
DataGridView.HitTestInfo info2 = dataGridView2.HitTest(e.X, e.Y);
if (info2.RowIndex >= 0)
{
if (info2.RowIndex >= 0 && info2.ColumnIndex >= 0)
{
string baluba = (System.String)e.Data.GetData(typeof(System.String));
if (baluba != null)
{
dataGridView2.CurrentCell.Value = baluba;
// dataGridView2.Rows[info2.RowIndex].Cells[info2.ColumnIndex].Value = baluba; --also tryed
//dataGridView2.DoDragDrop(baluba, DragDropEffects.Move);
}
}
}
}
}
private void dataGridView2_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Copy;
}
and off course in Designer.cs i have:
CODE
this.dataGridView2.AllowDrop = true;
this.dataGridView2.AutoGenerateColumns = false;
this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
this.sUPLNODataGridViewTextBoxColumn,
this.sKEYDataGridViewTextBoxColumn,
this.C3,
this.C4});
this.dataGridView2.DataSource = this.sUPLBindingSource;
this.dataGridView2.Location = new System.Drawing.Point(16, 13);
this.dataGridView2.MultiSelect = false;
this.dataGridView2.Name = "dataGridView2";
this.dataGridView2.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
this.dataGridView2.Size = new System.Drawing.Size(444, 150);
this.dataGridView2.TabIndex = 5;
this.dataGridView2.DragEnter += new System.Windows.Forms.DragEventHandler(this.dataGridView2_DragEnter);
this.dataGridView2.DragDrop += new System.Windows.Forms.DragEventHandler(this.dataGridView2_DragDrop);
this.dataGridView2.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView2_CellContentClick);