Don't put these calls into the InitializeComponent call. This method is "owned" by the design environment and abything the designer can't understand will vanish when the deigner recreates the method (which is everytime something changes in the design view). If you want these method calls to be generated, in other words you want to make sure your code gets called by the designer, you could implement ISupportInitialize. When a control/component trhat implements ISupportInitialize is dropped on to the design surface, the compiler emits a call to ISupportInitialize.BeginInit and ISupportInitialize.EndInit into InitializeComponent. So if you are happy to have your method calls executed *before* the designer emits your property sets then you could put your method calls inside your ISupportInitialize.BeginInit.
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<
[email protected]>
Hi,
Thanks for your reply. I am talking about windows forms. I am trying to
autogenerate code for method call. The generated code should look something
like this...'this.usercontrol.addmethod(somevariable);'. But when I call the
method from Initialize component, it just runs that part of the code but
does not generate code in the windows form designer. Hope you understand the
situation now.