all groups > visual studio .net ide > october 2003 >
You're in the

visual studio .net ide

group:

ComponentDesigner accessisg form to add objects


ComponentDesigner accessisg form to add objects Arul
10/30/2003 9:53:35 AM
visual studio .net ide:
I'm working on a Component Designer, and in one of my
Designer Verb's event handlers, I would like to
conditionally add another component to the form. Something
similar to this is done in the Data Adapter configuration
wizards when they add new connections or commands to the
form. Can anyone tell me the proper way to access the form
or to add new components to a form from another
component's designer? How does one access the collection
of components that already exist on a form?

Thanks-
RE: ComponentDesigner accessisg form to add objects v-yiy NO[at]SPAM online.microsoft.com
10/31/2003 2:35:13 PM
Hi Arul,
To my understanding now, you want to add a new component onto your form.
You need use the IDesignerHost interface to Create the Component, then add
it the Container of your component. Here is some pseudo code
<code>
//In a method of the designer
// Requests an IDesignerHost service from the design time environment using
Component.Site.GetService()
IDesignerHost dh = (IDesignerHost)
this.Component.Site.GetService(typeof(IDesignerHost));
IComponent cmp = dh.CreateComponent(typeof(YourComponent));
this.Component.Site.Container.Add(cmp);
</code>
If you have anything unclear about this issue, please be free to reply to
the group.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

RE: ComponentDesigner accessisg form to add objects Arul
11/3/2003 10:36:47 AM
Thanks Yu-
Yes, the IDesignerHost is what I needed. Looks like I have
a lot of work yet to do (stepping through existing
components, nested object generation, etc.). I haven't
found many good articles or examples on this interface. I
found "Customize Code Generation in the .NET Framework
Visual Designers". Are there any other resources you might
recommend?

Thanks-
Arul

[quoted text, click to view]
RE: ComponentDesigner accessisg form to add objects v-yiy NO[at]SPAM online.microsoft.com (
11/4/2003 2:40:02 AM
Hi Arul,
You may search "Shawn Burke" in the MSDN library, it will give you a list
of tech articles on how to programming in design-time. Here is another link
page which has a lot of useful links, it will give a good start:
http://www.tmgdevelopment.co.uk/developerdotnetlinks.html
Ofcourse, if you have any questions and ideas on it, please be free to
share with the community.
Thanks for using MSDN Newsgroup!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

AddThis Social Bookmark Button