logo       

Re: Where is my User Control: msg#00371

windows.devel.dotnet.winforms

Subject: Re: Where is my User Control

Griffiths, Ian wrote:
>
> > Many's the time I've just dropped some other control type onto
> > the form and then done a search and replace to replace it with
> > my control type.
>
Fabian Schmied replied:
> Wow, that's a great idea, so simple yet so effective.

Before anyone else tries this and breaks their forms, I feel I should
point out two things:

(1) Make sure that the placeholder control you put down and plan to
replace is the only control of its type on the form. (Otherwise you'll
replace all the other ones too!)

(2) Be aware that by using this trick, you're editing the contents of
InitializeComponent here, which can sometimes confuse the Forms
Designer. It owns that method, and if you put code in there that it
doesn't understand (i.e. code that doesn't look like something the Forms
Designer would have generated) typically deletes that code next time you
change the form. (To be fair, there are great big warnings in the
source code telling you not to edit this function...)

So it's a good idea to take backups, or check stuff into source control
before making this kind of change, because it might be more destructive
than you intended... (But it's still a useful trick.)


--
Ian Griffiths - DevelopMentor
http://www.interact-sw.co.uk/iangblog/



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise