473,509 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

When does a closed form go to Nothing?

When launching another form from the current form, I use the code below to
determine if the form to be launched is already active and showing. If
form = Nothing, then I instantiate it, otherwise I just set it's properties
and refresh the form.

Problem is: when the form already been shown and closed using it's X button
(sending the form thru it's Closing and Disposed events), and then an
attempt is made to reinstantiate it again, the form is NOT Nothing, and
falls into the Else clause below. This generates an error message"

"Cannot access a disposed objected named "frmRecord". Object name:
"frmRecord".

Is this a case of slow garbage collection, and/or is there a way to set a
form to Nothing in the form's Closing or Disposed events?

If frmRecord Is Nothing Then
frmRecord = New frmRecord(intFormatID, intRecordID, FormMode.Edit)

frmRecord.Show()

Else

frmRecord.Mode = FormMode.Edit

frmRecord.RecordID = intRecordID

frmRecord.FormPaint(intRecordID)

frmRecord.Show()

End If

Thanks,

Dean Slindee
Nov 20 '05 #1
3 1428
"Dean Slindee" <sl*****@charter.net> schrieb
When launching another form from the current form, I use the code
below to determine if the form to be launched is already active and
showing. If form = Nothing, then I instantiate it, otherwise I just
set it's properties and refresh the form.

Problem is: when the form already been shown and closed using it's X
button (sending the form thru it's Closing and Disposed events), and
then an attempt is made to reinstantiate it again, the form is NOT
Nothing, and falls into the Else clause below. This generates an
error message"

"Cannot access a disposed objected named "frmRecord". Object
name: "frmRecord".

Is this a case of slow garbage collection, and/or is there a way to
set a form to Nothing in the form's Closing or Disposed events?


Handle the other Form's closed event, and in the event handler, set the
variable = Nothing.

Or:
If frmRecord Is Nothing OrElse frmRecord.IsDisposed Then
frmRecord = New frmRecord(intFormatID, intRecordID, FormMode.Edit)
Else
frmRecord.Mode = FormMode.Edit
frmRecord.RecordID = intRecordID
frmRecord.FormPaint(intRecordID)
End If

frmRecord.Show()
frmRecord.activate
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
ISK
this isn't related to the actuall question - however, when I was looking for
isdisposed, it wouldn't show up in the intellisense neither for the form nor
for an object of type 'Control'. ofocurse, it shows up in the object browser
for the Control. am i missing something here?
"Armin Zingler" wrote:
"Dean Slindee" <sl*****@charter.net> schrieb
When launching another form from the current form, I use the code
below to determine if the form to be launched is already active and
showing. If form = Nothing, then I instantiate it, otherwise I just
set it's properties and refresh the form.

Problem is: when the form already been shown and closed using it's X
button (sending the form thru it's Closing and Disposed events), and
then an attempt is made to reinstantiate it again, the form is NOT
Nothing, and falls into the Else clause below. This generates an
error message"

"Cannot access a disposed objected named "frmRecord". Object
name: "frmRecord".

Is this a case of slow garbage collection, and/or is there a way to
set a form to Nothing in the form's Closing or Disposed events?


Handle the other Form's closed event, and in the event handler, set the
variable = Nothing.

Or:
If frmRecord Is Nothing OrElse frmRecord.IsDisposed Then
frmRecord = New frmRecord(intFormatID, intRecordID, FormMode.Edit)
Else
frmRecord.Mode = FormMode.Edit
frmRecord.RecordID = intRecordID
frmRecord.FormPaint(intRecordID)
End If

frmRecord.Show()
frmRecord.activate
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3
"ISK" <IS*@discussions.microsoft.com> schrieb
this isn't related to the actuall question - however, when I was
looking for isdisposed, it wouldn't show up in the intellisense
neither for the form nor for an object of type 'Control'. ofocurse,
it shows up in the object browser for the Control. am i missing
something here?


Menu Tools -> Options: Text-Editor -> Basic -> General: uncheck "Hide
advanced members"
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #4

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

Similar topics

5
4407
by: Matt Kruse | last post by:
See: http://www.mattkruse.com/temp/window_closed.html It looks like the .closed property of a window is inaccessible if the window is actually closed. Other browsers have no problem detecting...
5
3361
by: Bob | last post by:
Hi Everybody I have a form called frmListBox that is connected to a table tblListBox. This is opened from a form called "frmInvoiceOrder" which has a subform called "zfrmInvoiceOrder" and...
5
9093
by: news.microsoft.com | last post by:
Hi everyone, I need some help (may be in the form of some sample code) for the subject question. I have an ASP.NET/C# application. I need to do quite a few tasks when the session ends. I...
4
10001
by: Ali | last post by:
i am using visual studio 2005 and I am trying to create a popup calender so when a user click on a image on the main form, a calender will then popup, the user will select a date and the date will...
9
4888
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
3
1291
by: RD | last post by:
Dim myfrm as new frmb myfrm.show() Dim myfrm2 as new frmc myfrm2.show Opens two forms from a butom located on forma when I close forma I would like both form myfrm and for myfrm2 to close...
21
1666
by: SamSpade | last post by:
I declare a variable X of type myForm then instantiate myForm saving a reference in the variable X, and then do X.Show. If I need to know if the form has been shown yet, I check X against...
1
1409
by: SamSpade | last post by:
I need a MDI form to be notified when one of it's child closes. I could define an event in each child and raise it when it closes. But if there is some WinProc message that occurs when a child...
3
4368
by: Simon Verona | last post by:
I have a parent form which contains a toolbar. The toolbar controls the loading and switching to of MDI child forms. The code for the toolbar click event and one of the subroutines that loads...
0
7135
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
7342
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
7410
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...
1
7067
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...
0
5650
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,...
1
5060
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...
0
3215
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...
0
1570
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 ...
0
440
bsmnconsultancy
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...

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.