473,406 Members | 2,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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
3 3584
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
"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
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Yasutaka Ito | last post by:
Hi folks! I have a BaseForm class that inherits System.Windows.Forms.Form. It has a property, whose value I need supplied by the class that inherits it. The BaseForm usees the value supplied...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
13
by: z. f. | last post by:
Hi, i have a class that is derived from System.Web.UI.Page, and this is the class i use in my application as PageBase. all other page classes are deriverd from my PageBase instead of the...
1
by: Anatoly | last post by:
We have some base classes library which includes also base web form class. In every new project we adding one web form class which inherits from our base class web form. All other web forms in...
1
by: Murray Gill | last post by:
Our current solution has a number of ASP.NET pages with very similar functionality. We would like to move the common functions into a base class that inherits from System.Web.UI.Page, and then force...
0
by: Benjamin Bittner | last post by:
Hallo NG, ive searched a lot in some google groups, and found many threads, but nothing that helped me. Here is the scenario: I have an aspx page which loads a user control in page.onInit like...
7
by: | last post by:
I am having trouble figuring out to call a database INSERT procedure from a simple submit form. It appears I should use the onclick event to trigger the procedure called BUT when I do this I...
4
by: C M Shaw | last post by:
I have a form which I want to show modally; it's a fairly old form that's been ported up several versions of VB, and I'd like to keep its rewriting to a minimum. Basically, it is used in this...
3
by: Dennis | last post by:
I have the following code for showing a form: dim frm as new myForm frm.ShowDialog (The Form Load Event is fired then I hide the form using Me.Hide when the X in the UR corner is clicked). ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.