473,796 Members | 2,565 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Form Load Event Behavior...

I am experiencing some unexpected behavior with the Form Load event in a
Windows application. Hopefully, someone can explain why this behavior is
occurring.

In my application, I have a form that I would like to show multiple times
throughout the life of the application. The startup code for this form can
be quite lengthy so I am hiding and showning the form (versus unloading and
loading it). If I show the form non-modally (using the Show method), the
code in the Load event is fired only one time. If I show the form modally
(using the ShowDialog method), the code in the Load event is fired every time
I make the form visible.

Is there an explanation as to why this behavior is occuring?

Thank you,

Jason Richmeier
Apr 25 '06 #1
1 2261
Hi Jason,

Thank you for posting.

As you know, it's different for a winform to display modal or modeless.

Firstly, if a winform is loaded for the first time, whether in the modal
mode or modeless mode, the load event of the winform will be raised.

Secondly, after the winform is shown modeless, the program control will
return to the place where the sentence called to open the form is and the
code following this sentence will be executed. On the contrary, if the
winform is shown modal, the code following the sentence will not executed
until the winform is closed.

Thirdly, if you hide a modeless winform , the winform will be invisible but
not be unloaded. While if you hide a modal winform , the winform will be
invisible and unloaded but not disposed. The code following the sentence
that showes the winform in the modal mode will be executed now. Then if
you show a modeless winform again, the winform will be visible again but
the load event will not be raised. While if you show a modal winform
again, the winform will be loaded again and the load event will be raised.

Hope I am making sense.

If you have any other concerns or need anything else, please don't hesitate
to tell me.

Sincerely,
Linda Liu
Microsoft Online Community Support

=============== =============== =============== =======
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
=============== =============== =============== =======

Apr 26 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2326
by: ThunderMusic | last post by:
Hi, I'm trying to have a MSN Messenger like form/app closing behavior. When I click on the X button, I only want the form to disappear and when I double-click on the notify icon or right-click on it and choose Open from the context menu, I want the form to reappear. For that, I got the point covered. Even when the form is minimize, the behavior is like MSN Messenger. But one problem arose. When I close the form (the first time), it...
3
4208
by: MrNobody | last post by:
I'm pretty tired from working all day on this program and this one simple task of showing a certain form when the app initializes is driving me nuts... It opens very briefly then quickly disappears... I put Console.WriteLines in the Closing event and the Dispose event and he VisibleChanged events to see if any of them are called and only the visibility is changed (probable from when I call Show() ) Just in case I even put...
3
3313
by: Matt | last post by:
Hello, I just don't get it. I have a simple webform1.aspx page, when loaded for the first time, the load even fires which is fine. In webform1.aspx i have a button that has a onclick event, and in this event i do a response.redirect to webform2.aspx page. However on the onclick event of the button, the Load event for webform1.aspx is loaded again! Then the redirection is done!
7
2639
by: Tyler Foreman | last post by:
Hello, I have a strange problem that occurs every so often in my application. It usually takes place when I hide one form and activate another. What happens is I get the following exception: System.ArgumentException occured in System.Windows.Forms.dll
3
3618
by: feng | last post by:
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,...
4
5834
by: ThunderMusic | last post by:
Hi, I have a custom form that works fine when I debug it or run it in release mode but cannot be loaded in the designer... Actually, it can be loaded in the designer when no control is on it, but the resizing tool (in the designer) is offset both horizontally and vertically and when I put a control on it, as soon as I save, the designer throws an exception (but cannot be reproduced everytime) and the form cannot be loaded anymore unless...
7
9902
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I've noticed that a form will cover the taskbar when it is maximized if its ControlBox property is set to false (even if the "Keep the taskbar on top of other windows" option is selected). You can reproduce this by showing the following form: Public Class Form1 Inherits Windows.Forms.Form Public Sub New() MyBase.New() Me.ControlBox = False
2
2889
by: Peted | last post by:
Hi Im using c# express edition 2005 I have an MDI form, where i load multiple child forms from a dll i create, using reflection and late binding The child forms have multiple radio buttons in a groupbox, and have the appearence set to button
6
2239
by: Steve | last post by:
Hi All I have an on-screen keyboard within a POS program I have written in VB.net 2005, for touch screen computers I have it set to 'always on top' so the user can move the cursor to different text boxes and type using the on-screen keyboard The keyboard launches via the mouseclick event for any text box If another form is launched, with the onscreen keyboard still visible, the
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9531
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10459
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10187
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7553
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6795
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5578
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.