Check is form is disposed

R

rob willaar

Hi,

How can i check is a form is disposed in framework 1.1
In framework 2.0 i can check Form.IsDisposed to check if a user closed the
form
 
I

Imran Koradia

You have the IsDisposed property in 1.1 as well. However, the difference
here is that you will need a reference to the instance of the form unlike in
2.0 where you can just call the class name as you would do in VB 6.0.

However, I'm not sure if IsDisposed is the best way to determine whether a
form is closed or not. Its better to use the Closed event of the form within
which you can set some boolean indicating that the form has been closed.

for example:
Private bFormClosed as boolean = False

private sub Form1_Load(byval sender as System.Object, byval e as
System.EventArgs) _
Handles Form1.Load
bFormClosed = False
end sub

private sub Form1_Closed(byval sender as System.Object, byval e as
System.EventArgs) _
Handles Form1.Closed
bFormClosed = True
end sub

then check the bFormClosed variable to determine whether the form is closed
or not.

hope this helps..
Imran.
 
R

rob willaar

Hi Imran,

Tnx for your reply.

I don't seem to have a .IsDisposed property on a reference to a form in
framework 1.1
This app will have a lot of forms so i don't like to have globals
 
I

Imran Koradia

IsDisposed is inherited from the Control Class.
Maybe something like this is what you need then:

If CType(oMyForm, Control).IsDisposed then
'do something
end if

hope this helps..
Imran.
 
C

Cor Ligthert

Rob,

I agree with Imran,

When a form is disposed means that it is been opened before.

Gives crazy program control in my opinion.

(By the way, a user does not close a form, that is done by your program)

Just my 2 cents

Cor
 

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