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

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
 
J

Jack Jackson

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.
 
O

olympus_mons

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top