Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / April 2005

Tip: Looking for answers? Try searching our database.

Trappping when a control is created

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Robby White - 21 Apr 2005 04:07 GMT
I have looked in the events automation sample and cant seem to find any
example of how to monitor for when a new control is created to then set some
default properties. Any help or direction appreciated...

Cheers, Robby
Carlos J. Quintero [.NET MVP] - 21 Apr 2005 09:41 GMT
Hi Robby,

You need to get the IDesignerHost of the designer Window, get its
System.ComponentModel.Design.IComponentChange service.

The following article of mine shows how to retrieve services from the
IDesignerHost:

HOWTO: Manipulating controls of Windows forms from Visual Studio .NET
add-ins
http://support.microsoft.com/default.aspx?scid=kb;en-us;555170

Then you need to trap the ComponentAdded event of IConmponentChangeService,
but since the event is fired before the control is completely sited,
altering properties at that moment is pointless since they will be
overwritten, so you need to use the ComponentChanged event with the
"Controls" property in those cases. The consequence is that it is very
tricky and it takes quite time to make it work correctly in all cases. If
you want this info to build your own add-in it is fine, but if you need it
for your own use, my add-in (below) has a Control Default Properties feature
that would meet your needs.

Signature

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

>I have looked in the events automation sample and cant seem to find any
> example of how to monitor for when a new control is created to then set
> some
> default properties. Any help or direction appreciated...
>
> Cheers, Robby
Robby White - 22 Apr 2005 06:57 GMT
I would very much like an example of this tricky code as I am developing an
add-in for code and control templates.  My control templates are deep as they
can drill down into collections, add objects and set properties, however I
want the ability to set default control templates also.

I used to use your tools for VB6 and have browsed the .NET ones also.  

So tell me do you single handedly create and maintain all things
extensibility!

Cheers, Robby

> Hi Robby,
>
[quoted text clipped - 24 lines]
> >
> > Cheers, Robby
Carlos J. Quintero [.NET MVP] - 22 Apr 2005 10:08 GMT
>I would very much like an example of this tricky code as I am developing an
> add-in for code and control templates.

I can´t provide the code directly but I can assist you with the problems
that you encounter. So, start getting the IComponentChangeService interface,
trapping its events and setting new default properties as explained in the
article.

> I used to use your tools for VB6 and have browsed the .NET ones also.
> So tell me do you single handedly create and maintain all things
> extensibility!

Yes, I have spent my last years since 2000 dealing with extensibility of MS
tools, and answering questions about them. If you have not visited it yet, I
recommend you to join (free) the yahoo forum
http://groups.yahoo.com/group/vsnetaddin/, the best one of the web, which is
more specific for .NET add-ins. You have also lots of resources on my web
site.

Signature

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.