473,385 Members | 2,210 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,385 software developers and data experts.

Dipose() Doubts

Hi...

I have a main MDI form where I load (in a menu click method) my MDI child
forms, like in example below:

private void tStpPrincipalUsers_Click(object sender, EventArgs e)
{
FormUsers frmUsers = new FormUsers();
frmUsers.MdiParent = this;
frmUsers.WindowState = FormWindowState.Maximized;
frmUsers.Show();
}

In the frmUsers I have this method in a tool bar button:

private void tStpBtnExit_Click(object sender, EventArgs e)
{
this.Close();
this.Dispose();
}

Is right call the dispose method here? If is not right where do I shall the
dispose method?

Other doubt is: I have a form loaded like a Dlg (called by the ShowDialog
method):

private void tStpBtnEdit_Click(object sender, EventArgs e)
{
DlgUsers userDlg = new DlgUsers();
userDlg.userID =
Convert.ToInt32(dataGridView1.CurrentRow.Cells["ID"].Value);
userDlg.LoadUser();
userDlg.ShowDialog();
userDlg.Dispose();
}

Is right call the dispose method here?
Mar 31 '06 #1
4 1388
With regard to your ShowDialog, wrap it all in a using statement and
the form will be automatically disposed for you

using(DlgUsers userDlg = new DlgUsers())
{
userDlg.userID =
Convert.ToInt32(dataGridView1.CurrentRow.Cells["ID"].Value);
userDlg.LoadUser();
userDlg.ShowDialog();
}

Mar 31 '06 #2
As Jason, wrap the ShowDialog form in a using and it will be disposed.
For a form shown using .Show, it is automatically disposed when it is
closed.

Mar 31 '06 #3
Chris, if the form is a MDI child form is it automatically disposed when it
is closed too?

"Chris Dunaway" <du******@gmail.com> escreveu na mensagem
news:11**********************@i39g2000cwa.googlegr oups.com...
As Jason, wrap the ShowDialog form in a using and it will be disposed.
For a form shown using .Show, it is automatically disposed when it is
closed.

Apr 3 '06 #4
I cannot find any information that an MDI form behaves differently than
any other form. AFAIK, when a form is closed that was shown with just
the Show method, it is disposed.

Apr 3 '06 #5

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

Similar topics

0
by: abbas reji | last post by:
--0-599929911-1059996886=:4358 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-Id: Content-Disposition: inline ...
1
by: Piotre Ugrumov | last post by:
I have some problems and some doubts. I have implemented a class hierachy. The base class Velivolo, from Velivolo derive Militare and Civile, from militare derive Aereo and Elicottero, from Civile...
6
by: ritesh | last post by:
Hi, I have been reading some text on C and C++ (i.e advanced books). One of the books mentioned that C++ requires a runtime support whereas C does not - what the author was trying to say was...
17
by: ranjeet.gupta | last post by:
Dear All Below are the few doubts which I got while studying about C 1. Is there any method in C by which we can process the entire string in one unit, 2. Does there exist any way to...
13
by: maadhuu | last post by:
hello everybody, i have 2 doubts . 1. is this always defined ?? int i =10; int a = i++ + i++; and also, i tried this in gcc, answer was 20, so what the sequence points for evaluation of...
6
by: Chua Wen Ching | last post by:
Hi there, I have some questions to ask... just say i have this xml file: Scenario :- Script.xml ======== <software> <settings>
2
by: VMI | last post by:
I'm having doubts as to how the compiler interprets this If statement: bool bIsTrue = true; if (! bIsTrue) { //RUN PROCESS } Here, will "RUN PROCESS" be executed? Or is this just wrong?...
1
by: Chris Leffer | last post by:
Hi. Reading some Microsoft materials about asp.net I came into two doubts. The following sentence is found on the topic "Application State" in the NET Framework documentation: "Calling Lock...
4
by: project | last post by:
Anybody can solve following doubts? 1. Normalization rules. 2. Garbage Collection 3.LinkList Posted Via Usenet.com Premium Usenet Newsgroup Services...
1
by: NagaKiran | last post by:
Hi I want to post VBA related doubts. Where can I post my doubts in VBA? thanks bye
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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.