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 to second Forms control with custom data

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



Joined: 16 Jun 2010
Posts: 1

PostPosted: Wed Jun 16, 2010 4:53 pm    Post subject: Drag and Drop to second Forms control with custom data Reply with quote

I've been over the forums a bit and haven't found an answer to this question. I apologize if it's already been asked. Smile

Is there a way to have the drag and drop data filled out by me (the user) either as a result of some event firing or function overriding? I'd rather not have the DoDragDrop event of the receiving control receive a list of Row objects, as that sort of breaks the encapsulation of data that I'm trying to construct. I'd rather be given the option of filling out my own data structure as a result of starting a drag operation from the tree, then have the tree pass that structure to the DataEventArgs.Data property.

Is there any way to accomplish this?

Thanks!
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Wed Jun 16, 2010 10:46 pm    Post subject: Reply with quote

To do this you would need to create a custom RowWidget (see the section in help on using Widgets) and override the DoDragDrop method. The default implementation is shown below:

Code:
protected virtual void DoDragDrop()
{
    SelectOnMouseUp = false;
    Dragging = true;
    Tree.CompleteEdit();
    SetDragCursors();
    WidgetControl.DoDragDrop(this, Tree.SelectedRows.GetRows(), DragDropEffects.All | DragDropEffects.Link);
    DestroyDragCursors();
    Dragging = false;
}


Instead of passing the Tree.SelectedRows.GetRows() you would need to put your own data. An alternative (possibly easier/better) would be to override the VirtualTree.DoDragDrop method and convert the data from rows to whatever format you want there before calling the base method eg

Code:
public override void DoDragDrop(Widget widget, object data, DragDropEffects allowedEffects)
{
    Row[] rows = data as Row[];
    if (rows != null)
    {
        // extract your data from the rows here and format - the code below
        // just gets the first selected item
        //
        object newData = rows[0].Item;
        base.DoDragDrop(widget, newData, allowedEffects);
    }
}

_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
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