PC Review


Reply
Thread Tools Rate Thread

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

 
 
feng
Guest
Posts: n/a
 
      10th Oct 2003
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

 
Reply With Quote
 
 
 
 
Fergus Cooney
Guest
Posts: n/a
 
      10th Oct 2003
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


 
Reply With Quote
 
Armin Zingler
Guest
Posts: n/a
 
      10th Oct 2003
"feng" <(E-Mail Removed)> 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

 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      10th Oct 2003
* "feng" <(E-Mail Removed)> 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>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Form.Closing event not fired always when i call Form.Close method berylwilson Microsoft Dot NET Framework Forms 1 20th Apr 2007 02:11 AM
Form designer problem - cannot load a form Alan T Microsoft C# .NET 5 10th Nov 2006 04:25 AM
Web form designer in VS 2003 .Net does not know about base classcontrols Edward Diener Microsoft ASP .NET 0 20th Jul 2006 06:29 PM
Form designer fails to load inherited form =?Utf-8?B?RHJKb2hu?= Microsoft Dot NET Framework Forms 1 25th Nov 2005 12:28 AM
Base's load event fires when inheriting form in design view Enrico Angka Microsoft Dot NET Framework Forms 1 5th Sep 2003 10:25 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:10 AM.