Data can't be copied to dataset in datagridview from treeview

Metager [Bot]

New Member
I want to drop some data from treeview to the datagridview temporarily, but the datagrid view is already loaded some data from a xml file.Someone Please explain to me the mechanism of this.This is my drag/drop function: //It works perfectly if there is no data in the datagrid view.\[code\] private void DataGridView1OnDragDrop(object sender, DragEventArgs e) { Point dscreen = new Point(e.X, e.Y); Point dclient = dataGridView1.PointToClient(dscreen); DataGridView.HitTestInfo hitTest = dataGridView1.HitTest(dclient.X, dclient.Y); if (hitTest.ColumnIndex == 0 && hitTest.Type == DataGridViewHitTestType.Cell) { e.Effect = DragDropEffects.Move; //dataGridView1.Rows.Insert(hitTest.RowIndex, "hitTest", "hitTest", "hitTest", "hitTest"); var data = http://stackoverflow.com/questions/11109712/(object[]) e.Data.GetData(typeof(string[])); dataGridView1.Rows.Insert(hitTest.RowIndex, data); } else { e.Effect = DragDropEffects.None; } dataGridView1.AllowUserToAddRows = false; }\[/code\]For datagrid:\[code\]XmlReader xmlFile;xmlFile = XmlReader.Create("Product.xml", new XmlReaderSettings());DataSet ds = new DataSet();ds.ReadXml(xmlFile);dataGridView1.DataSource = ds.Tables[0];\[/code\]For Treeview:\[code\]var filename = @"C:\Check.xml";//First, we'll load the Xml documentXmlDocument xDoc = new XmlDocument();xDoc.Load(filename);\[/code\]
 
Back
Top