How to ensure that a form is disposed?
When I work with modal forms I do the following:
using (Form1 frm = new Form1())
{
frm.ShowDialog( );
}
As far as I read, when it ends the using scope, the form is disposed.
But if I don't use modal forms, like this:
Form1 frm = new Form1();
frm.Show();
In this case, when the user clicks on the X button, or a close button,
the form is disposed?
Junior. 1 2526
Junior,
Yes, when the user clicks on the close button, the form is disposed of.
When the message to close is received for the form, it calls Dispose.
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m
"osmarjunio r" <os*********@gm ail.comwrote in message
news:11******** **************@ m7g2000cwm.goog legroups.com...
How to ensure that a form is disposed?
When I work with modal forms I do the following:
using (Form1 frm = new Form1())
{
frm.ShowDialog( );
}
As far as I read, when it ends the using scope, the form is disposed.
But if I don't use modal forms, like this:
Form1 frm = new Form1();
frm.Show();
In this case, when the user clicks on the X button, or a close button,
the form is disposed?
Junior. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: EMW |
last post by:
I have one form which is my main form and has 4 option buttons and two
regular buttons, one for saving and the other for canceling the program.
When the user select an option button, a new form is opened and he can fill
in some fields by using a context menu (standard answers).
When he is finished, tapping on the save button, the form is hidden and the
user is returned to the main form, where an image is drawn that the form is
filled in...
|
by: D Witherspoon |
last post by:
I use the following code to open up a form.
-------------------------------------------------------
If fImage Is Nothing Then
fImage = New frmImage
End If
fImage.Show()
|
by: Sean Connery |
last post by:
I have a Microsoft UI Process Application Block that is controlling child
forms in an MDI parent container. The views node in the app.config file has
been set to stayOpen=false.
Because there are a series of data entry forms using ONLY the numeric key
pad, certain keys on this pad have been configured to behave as "function
keys". In order for this to happen, I have implemented the IMessageFilter
interface to intercept messages in the...
|
by: bole2cant |
last post by:
The error I get is:
Cannot access a disposed Object named "Form2".
Object name "Form2".
Here is the sequence which gives the error.
Start program. Form1 comes up and has a button to choose Form2.
Go to Form2. Close Form2 when done. Now back on Form1.
Click button to go back to Form2. The error/exception comes up.
I originally got this error when using Me.Close(), so I changed it to Me.Hide() and everything was fine. Except now when...
|
by: Boni |
last post by:
Dear all,
if I do myform.close() is it disposed or not?
is it correct do following?
myForm.close()
Info=SomeControlOntheForm.text
This seems to work. But am not sure that it is waterproof.
Thanks,
Boni
| |
by: Zytan |
last post by:
I have created a new form from the main form. When I close the main
form with the 'x' close button, its Form.FormClosed event is run, but
not the dialog's.
Is this normal? It is ok / dangerous? How can I force shutdown code
within the dialog's Form.FormClosed event run?
Zytan
|
by: aine_canby |
last post by:
Hi,
The problem is that the line -
this.Invoke(new MyDelegate(Function), args); // this = MainForm
is being called after the line -
terminatePopulate = true;
therefore I get an exception which states that MainForm has been
disposed when this.Invoke is called...
|
by: rbrowning1958 |
last post by:
Hello,
I am confused by dispose etc. and hope someone can set me right.
1. The Dispose(Bool) the IDE generates for a form has nothing to do
with IDisposable, right?
2. So when is this called? When a form is closed? If this is caused
automatically when a form is closed how can I then access things on a
modal from after ShowDialog() returns? Or is it only for modeless
forms?
|
by: BillE |
last post by:
Using vb.net 2008 windows forms.
How can a form which has been closed and disposed still attempt to handle a
custom event?
I have a form which inherits from a base form class.
The base class has a shared event which is raised when a property in the
base class changes (the property updates a shared variable value).
|
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...
|
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,...
| |
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |