Design time Drag and Drop

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

we have this custom control we have designed. We want to allow the user in
VS .NET 2005 environment to drag another control onto our control at design
time and receive information of what type of control was dragged onto it. Any
help would be great. Thanks,
Matt
 
Solitude,

You need to create a designer for this control and attach it to the control
using the DesignerAttribute.

Make the designer to derive from ParentControlDesigner or
ScrollableControlDesigner (if your control supports scroll bars). In the
designer you can override CanParent virtutal method and check whether the
control can parent the type of the control that is about to be dropped. I
believe this is what you wanted.
 
Hi Solitude,

A design-time group would be a more appropriate place to ask your question,
but I do have some advice. Derive your control from Panel and you'll get
container designer support for free. To peek at controls that are added to
your control in the designer you can override the ControlAdded method. In
ControlAdded throw an Exception if a Control's Type is not valid as a child
of your Control.

HTH
 
Thanks,
that worked great, except that works for Drag and Drop.
But they can select the control in the toolbox without dragging it and click
on my control, this does not fire off the OnDragDrop or the CanParent events.
So how I can I prevent them from adding a control to my control using this
DesignerAttribute method. Thanks,

Solitude
 
Back
Top