window doesnt dispose on close???

G

Guest

i have an .ado project with multiple windows. i use this.close to close all
the windows, this makes it run through the closing and dispose functions.
there is 1 window that when closed will run through the closing function but
will not actually dispose until the project closes. any ideas why? the
function call and window calls are all the same, i'm just not sure if i
changed a property or something i didn't notice.
 
S

Stoitcho Goutsev \(100\) [C# MVP]

Oscar,

Is this window shown as a modal dialog (Form.ShowModal) in this case Close
method actually hides the form and doesn't dispose it. This is because
normally when dialog is closed one would want to read some of its fields or
maight want to reuse the dialog later.
 
G

Guest

the window is being called with ShowDialog()

Stoitcho Goutsev (100) said:
Oscar,

Is this window shown as a modal dialog (Form.ShowModal) in this case Close
method actually hides the form and doesn't dispose it. This is because
normally when dialog is closed one would want to read some of its fields or
maight want to reuse the dialog later.


--

Stoitcho Goutsev (100) [C# MVP]

oscar said:
i have an .ado project with multiple windows. i use this.close to close
all
the windows, this makes it run through the closing and dispose functions.
there is 1 window that when closed will run through the closing function
but
will not actually dispose until the project closes. any ideas why? the
function call and window calls are all the same, i'm just not sure if i
changed a property or something i didn't notice.
 
S

Stoitcho Goutsev \(100\) [C# MVP]

oscar,

In this case as I said the control is hidden and not disposed. You need to
call its Dispose mathod manually.
For example if you don't need to reuse the dialog you can shoe the dialog
like this:

using(MyDlg dlg = new MyDlg(this))
{
if(DialogResult.Ok == dlg.ShowDialog)
{
/// Consume the dialog box data
}
}

this way you'll have the dialog box form disposed as soon as the execution
leaves the using block


--
HTH
Stoitcho Goutsev (100) [C# MVP]

oscar said:
the window is being called with ShowDialog()

Stoitcho Goutsev (100) said:
Oscar,

Is this window shown as a modal dialog (Form.ShowModal) in this case
Close
method actually hides the form and doesn't dispose it. This is because
normally when dialog is closed one would want to read some of its fields
or
maight want to reuse the dialog later.


--

Stoitcho Goutsev (100) [C# MVP]

oscar said:
i have an .ado project with multiple windows. i use this.close to
close
all
the windows, this makes it run through the closing and dispose
functions.
there is 1 window that when closed will run through the closing
function
but
will not actually dispose until the project closes. any ideas why? the
function call and window calls are all the same, i'm just not sure if i
changed a property or something i didn't notice.
 
G

Guest

That's what I am currently doing, but why is it like this for 1 window? The
other 20 windows do not do this. Is there a setting within the window that
would cause this?
 
C

Chris Dunaway

Are the other windows also shown with ShowDialog or just Show? If they
are shown by calling just Show, then they are automatically disposed
when they are closed. If they are shown with ShowDialog, then you must
dispose them manually as Stoitcho said.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top