all groups > dotnet windows forms designtime > february 2005 >
You're in the

dotnet windows forms designtime

group:

Deserializing a dropped ToolBoxItem in a ParentControlDesigner.OnDragDrop function


Deserializing a dropped ToolBoxItem in a ParentControlDesigner.OnDragDrop function Robin Sanner
2/25/2005 12:49:37 PM
dotnet windows forms designtime:
Currently when a OnDragDrop event fires in my control designer I use
ISelectionService to get the component that was dropped. I know there has
to be a way to get the component out of the DragEventArgs.Data.GetData()
method but I have been unable to figure out how. When you drop a control
from the ToolBox DragEventArgs.Data.GetDatapresent(".NET Toolbox Item")
returns true and DragEventArgs.Data.GetData(".NET Toolbox Item") returns a
MemoryStream. IToolBoxService.IsToolBoxItem reports False.

I also can't figure out how to get the dropped object out of the
DragEventArgs when it's not a ToolBoxItem.

What is the right way to do this? I am currently using ISelectionService
and it works but there MUST be a way to get the object out of DragEventArgs.
What am I missing?

Thank you
Robin Sanner
robin.sanner@verizon.net

Re: Deserializing a dropped ToolBoxItem in aParentControlDesigner.OnDragDrop function Simon Lawrence
2/26/2005 10:48:32 AM
On 25/02/2005 8:49 PM, in article uXb1Gu3GFHA.2736@TK2MSFTNGP09.phx.gbl,
[quoted text, click to view]

Hi Robin,

[quoted text, click to view]

The object that is being dropped is the toolbox item rather than the new
component (see IToolboxService.DeserializeToolboxItem and
IToolboxItem.CreateComponents). The MSDN Shape Designer sample illustrates
what happens ( http://windowsforms.net/articles/shapedesigner.aspx - see the
discussion around the OnDragDrop handler in the article).

I'm not sure what it is you're trying to do but maybe the events on
IComponentChangeService (ComponentAdded, ComponentAdding etc.) might be an
easier way of achieving it.

Cheers,

Simon
AddThis Social Bookmark Button