View previous topic :: View next topic |
Author |
Message |
macu
Joined: 06 Jun 2006 Posts: 12
|
Posted: Tue Jun 06, 2006 3:53 pm Post subject: Drag and drop between Treeview and grid |
|
|
Is it possible to implement drag and drop functionality between data grid and treeeview . If so can you give me some clues how to do it ??
Best regards |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Jun 06, 2006 11:02 pm Post subject: |
|
|
Yes it is possible. The exact details depend on whether you want to drag from the tree to the grid or from the grid to the tree.
When dragging from Virtual Tree to the grid (or any other control) the data placed in the drag/drop IDataObject is an array of Row objects (the Rows being dragged). Typically you would handle the DragOver and DragDrop events in the target control with the following type of code to extract the row data:
Code: | using Infralution.Controls.VirtualTree;
...
protected override void OnDragDrop(DragEventArgs e)
{
Row[] rows = (Row[])e.Data.GetData(typeof(Row[]));
if (rows != null)
{
foreach (Row row in rows)
{
// do something with the dropped row
Object droppedItem = row.Item;
}
}
} |
When dragging data from another control to Virtual Tree you need to handle the following events:
- GetAllowedRowDropLocations - to determine the allowed locations for dropping the current data (ie on the row, above or below the row)
- GetRowDropEffect - to determine whether the data should be moved, copied or prevented
- RowDrop - to actually implement the dropping of the data on the target row.
If you are using Object or DataSet binding and want the default drag and drop behaviour of rows (in addition to being able to drop data from the other control) then when you handle these events you will need to get the RowBinding and call the appropriate method:
eg
Code: | RowBinding binding = _virtualTree.GetBindingForRow(e.Row);
binding.OnDrop(e.Row, e.DropLocation, e.Data, e.DropEffect); |
_________________ Infralution Support |
|
Back to top |
|
|
Guest
|
Posted: Wed Jun 07, 2006 8:13 am Post subject: |
|
|
thanks very much |
|
Back to top |
|
|
|