Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Drag and drop between Treeview and grid

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support
View previous topic :: View next topic  
Author Message
macu



Joined: 06 Jun 2006
Posts: 12

PostPosted: Tue Jun 06, 2006 3:53 pm    Post subject: Drag and drop between Treeview and grid Reply with quote

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
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Jun 06, 2006 11:02 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Guest






PostPosted: Wed Jun 07, 2006 8:13 am    Post subject: Reply with quote

thanks very much Very Happy
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Virtual Tree Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group