Groups | Blog | Home
all groups > dotnet windows forms designtime > november 2005 >

dotnet windows forms designtime : IDesignerHost manually add component



Lance Johnson
11/15/2005 7:10:28 PM
I have form setup to perform designing of a form. There's a toolbox that
you can design from and everything. However, one thing I can't figure out
how to do is manually add an item to be designed. Let's say that I want to
add a TextBox to this. How do I go about this? Do I need to use the
IDesignerHost, IRootDesigner, or what do I need to do?

And perhaps I'm going about this in the wrong way, but we're going to allow
users to layout a custom form themselves. And we'll control the basic
elements such as the location and such. And then I want to manually add
these to the design surface. Let me know if there's an easier way to do
this such as serializing and deserializing. I'm sure there is, but I can't
exactly find the articles for doing this.


Lance Johnson

InK_
11/16/2005 10:52:07 AM
Hi!

I had similar task and I had to implement IDesignerHost,
IContainer,IServiceContainer and etc. to do this.
Form will be in design time when you add it to your DesignerHost
implementation.You should detect when the contol was dropped to the design
surface and add it to the host using CreateComponent or AddComponent.
Implementation of INameCreationService, ISelectionService is also needed.

For more details you can read this article:
http://www.divil.co.uk/net/articles/designers/hosting.asp

Regards,
InK_

[quoted text, click to view]


Fitim Skenderi
12/8/2005 2:29:34 PM
Hi Lance,

You create a control manually as you would normally do. Then you need to get
IContainer interface from the ServiceContainer (the container that holds
IDesignerHost, IContainer, ...). This Interface has a method Add(...) which
accepts IComponent interface (which is implemented by any Windows control so
you do not need to worry there)

hope this helps

Fitim Skenderi


[quoted text, click to view]

AddThis Social Bookmark Button