InitializeComponent() question

  • Thread starter Thread starter talljames
  • Start date Start date
T

talljames

Have a basic question I am sure the answer is out there.

How do you stop the Visual Studio C# Designer from removing lines out
of the Initialize component that do not have a "this." in front of
them.

When I switch from the code view to the designer view it removes my
lines, which is a pain in the rear end. I have tried with static
variables using the namespace..but these are removed too in some
cases.

thanks
 
Hi talljames,

InitializeComponent is not the place where you should write your custom
code. The designer will keep rewriting that portion, deleting your code.

Put your init code following the "//TODO:" comment you could see just after
InitializeComponent is invoked in the Form_Load event.

HTH,
Rakesh
 
Back
Top