By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,495 Members | 1,322 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,495 IT Pros & Developers. It's quick & easy.

base form's load event gets fired when form designer open.

P: n/a
We have a windows form project that has multiple child
forms inherit from one base form. In our base form's form
load event handler, we have some common logic in there.
These common logic is needed by all the child forms when
they load up. So when a child form gets called, the base's
form load event handler gets called first, so is the
common logic, then the child's load event handler gets
executed.

So far, everything works fine, except one: the base form's
load event handler gets executed not only at run time, but
also at the design time, when the child form is opened in
the form designer! This is so problematic, bucause we get
errors each time we open the designer. That's because a
lots of things that our common logic needs to run are not
available at the design time (of course!).

Can someone tell me if this is expected behavior? Is there
a way we can skip this execution at design time? Or any
other suggestions?

Thanks

Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi Feng,

You can test whether you are in running within the Designer using the
DesignMode property.

Let me know if you have any problems using this. There have been issues
with UserControls. I don't know if it will be the same with inherited Forms.

Regards,
Fergus
Nov 20 '05 #2

P: n/a
"feng" <li******@msn.com> schrieb
We have a windows form project that has multiple child
forms inherit from one base form. In our base form's form
load event handler, we have some common logic in there.
These common logic is needed by all the child forms when
they load up. So when a child form gets called, the base's
form load event handler gets called first, so is the
common logic, then the child's load event handler gets
executed.

So far, everything works fine, except one: the base form's
load event handler gets executed not only at run time, but
also at the design time, when the child form is opened in
the form designer! This is so problematic, bucause we get
errors each time we open the designer. That's because a
lots of things that our common logic needs to run are not
available at the design time (of course!).

Can someone tell me if this is expected behavior? Is there
a way we can skip this execution at design time? Or any
other suggestions?

If Not Me.Designmode Then
'code
End If
--
Armin

Nov 20 '05 #3

P: n/a
* "feng" <li******@msn.com> scripsit:
So far, everything works fine, except one: the base form's
load event handler gets executed not only at run time, but
also at the design time, when the child form is opened in
the form designer! This is so problematic, bucause we get
errors each time we open the designer. That's because a
lots of things that our common logic needs to run are not
available at the design time (of course!).

Can someone tell me if this is expected behavior? Is there


Yes, this behavior is by design. You can check 'Me.DesignMode' in the
base form to execute the code only if the form is shown in design mode.

--
Herfried K. Wagner
MVP VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.