Hi,
We've got a custom designer working, we can drag items from our toolbox onto the design surface without any problem.
However, we want to handle dragging while holding down control - this should create a copy of the control.
When ctrl-dragging, the icon changes to a + to indicate that this is what it's going to do, but on releasing the mouse, nothing happens!
The MSDN magazine example from March 2006 has the same 'feature'.
What do we have to do to enable the creation of the new control
Many thanks,
Gary

How to handle Ctrl-Drag on design surface?
Naveen Yajaman - MSFT
Hey Doug,
How do you add the service We are looking for a service of type ComponentSerializationService, so if you are registering a type of CodeDomComponentSerializationService , we won't find it.
Martin
Ron Hinton
Hi Martin,
Thanks for the reply, sorry I was a bit unclear in my original post.
I mean if you click on a control that's already on the control surface (not from the toolbox), and hold down ctrl whilst moving it, then rather than moving the control it remains in its original location and a copy is created. You can see this in visual studio (drag a label onto a form. Click and drag the label whilst holding down ctrl and a copy is created).
Our app doesn't have this behaviour, and neither does the example in the March MSDN mag (http://msdn.microsoft.com/msdnmag/issues/06/03/DesignerHosting/default.aspx -- code is at http://download.microsoft.com/download/f/2/7/f279e71e-efb0-4155-873d-5554a0608523/DesignerHosting.exe )
Thanks again,
Gary
Mónika
Hm. Would it be possible for you to send a sample project
Martin
Giops
Martin,
Thank you for your help. I was able to get my cut and paste to work by providing the IDesignerSerializationService like you suggested.
Doug
JorgeV
Martin,
I am having a similar problem. I cannot get the ctrl-drag to work and I also cannot get the cut/copy/paste to work using the MenuCommandService.GlobalInvoke.
I tried to add the CodeDomComponentSerializationService to my IDesignerHost (the DesignSurface) but this did not fix the problems for me.
Any suggestions would be appreciated.
Doug
Raj_1234
Hi,
Okay that makes more sense.
The reason is that we need the ComponentSerializationService which the sample does not provide. When the control is dropped, we copy the controls that are in the drag-selection, and to do so we use the ComponentSerializationService.
If that service is provided, everything should work. I will contact Dinesh about the sample.
Martin
galwacco
I just added a CodeDomComponentSerializationService to the IDesignerHost and that did the job.
P.S. Thanks to Martin for the original reply.
JustinJ
Martin,
I am adding it as a ComponentSerializationService, but it is still not working.
Do I need to have a DesignerLoader to make this work
Doug
Adrianotiger
how can I install the ComponentSerializationService please tell me ,thanks ,my msn is :enet2008@hotmail.com
the version of my Vs.net is 'Microsoft Visual Stadio 2005 V8.0.50727.42'
the version of my Framework is 'Microsoft .NET Framework V 2.0.50727'
Amit Singh (Paxcel)
If I launch the application without source code modification, and I create a new Form using the codeDomLoader, the feature Ctrl-Drag partially works.
Indeed, if I add a Button from the Toolbox , I rezise it, I use the Ctrl-Drag in order to copy it, I will have a Button with the default size.
Please, can you explain me
CBInc
and added the code line:
this.AddService(typeof(ComponentSerializationService), new CodeDomComponentSerializationService(this));
to the constructors of the HostSurface class and I also took out the code that disabled the edit menu in the MainShell.AddTabForNewHost method.
If I create a new Form in the application and add a component to the form, the Ctrl-Drag works but all the edit functions (cut, copy, paste, etc) do not work.
Doug
XVID
Hi,
A drag and ctrl-drag off the toolbox should be handled the same way. It doesn't really make sense to make a copy of something you are dragging off the toolbox.
Can you point me to the sample code that is broken and I will try and take a look later.
Martin
Natan Drozd
Gabslost
This is because the implementation of the Paste command relies on the IDesignerSerializationService which doesn't exist.
To get this to work, you would have to supply this service. As you mention earlier a DesignerLoader should provide you this. CodeDomDesignerLoader is the guy you need to look at. Check out http://msdn2.microsoft.com/en-us/library/swx4cfaa(VS.80).aspx
Martin