View previous topic :: View next topic |
Author |
Message |
pflesher
Joined: 16 Jun 2010 Posts: 1
|
Posted: Wed Jun 16, 2010 4:53 pm Post subject: Drag and Drop to second Forms control with custom data |
|
|
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.
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Jun 16, 2010 10:46 pm Post subject: |
|
|
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 |
|
|
|