Inherited Load method of a windows forms class gets executed by designer window?

  • Thread starter Thread starter olympus_mons
  • Start date Start date
O

olympus_mons

Hi,

I'm struggling with my first C# form window class that I now want to
reuse in an inherited form window (visual inheritance). The form
window class defines a method for the load event. This method gets
automatically executed by the IDE in the derived form window, when I
change from the code window to the designer window.

Is this intended behaviour in VS2005? I'm in the design phase so I
would not expect any code to get executed by the IDE.

TIA,
Stefan
 
Yes it is the expected behavior. Also most events fire too, except
for mouse and keyboard events.

If you don't want that, put tests for form.DesignMode around the code
you don't want to run in the IDE.
 
Thanks for letting me know.

However I'm still a bit confused wether this "feature" is good or bad.
I have a somewhat "strange" feeling about code that gets executed by
the IDE just because I want to see my form window in the designer (to
be exact is only happens when I made changes to the code - if I just
switch between code and design window it will only get executed the
first time). What would this be good for?

My problem was, that I showed a dialog box on load to set some options
how the form should behave. In my case when the user clicked "Cancel"
I also close the form. One may argue wether this is a good design but
it leads to the designer not beeing able to display the form when I
just want to modify the design...

Hmmm... may be someone can tell me why this is an advantage...
Stefan
 
Back
Top