C#:Drag&Drop from treeview to dataset XML file

TH

New Member
I want to drag&drop from treeview to datagrid view. The code for \[code\]drag\[/code\] is working fine but the code for \[code\]drop\[/code\]is not working. Please tell me what is the mistake am i doing here???I couldn't new values to the dataset.\[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; var ds = (DataSet) dataGridView1.DataSource; dataGridView1.Rows.Insert(hitTest.RowIndex, "test", "test", "test", "test"); } else { e.Effect = DragDropEffects.None; } } private void getDataGridFromXml() { try { XmlReader xmlFile; xmlFile = XmlReader.Create(@"C:\Depth.xml", new XmlReaderSettings()); DataSet ds = new DataSet(); ds.ReadXml(xmlFile); dataGridView1.DataSource = ds.Tables[0]; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }\[/code\]XMl: \[code\]<Product><Apple><Type>Best</Type><Trace>Spain</Trace><Quantity>1000</Quantity><Description>Notihng</Description></Apple></Product>\[/code\]
 
Back
Top