|
-
Nov 1st, 2002, 10:24 AM
#1
Thread Starter
Lively Member
show a form after been closed
Hi All,
This may be a simple question but it surely borthered me a lot. Ok, i have a form A as
public frmA as new frmTypeA()
In the program, the form A is opened by
....
frmA.show
...
The problem is: after the frmA is closed, i.e., user clicks the X on the right-top of the form, the frmA gets disposed. Then, when it comes to frmA.show again, a error as " can not access a disposed object frmA" is thrown out . I tried to use the following code to solve the problem but doesn't work at all
if frmA is nothing then
frmA = new frmTypeA()
endif
frmA.show()
Any idea how to solve the problem ? I like .Net a lot , specially the OOP, shared class members, ...., etc. But under some circumstances, i miss the old VB6, the debug capability for an example.
-
Nov 1st, 2002, 11:19 AM
#2
Thread Starter
Lively Member
I think i found the answer. Instead of using
if frmA is nothing then
should use
if frmA.isdisposed() then
-
Nov 1st, 2002, 11:38 AM
#3
PowerPoster
Try puting this in the FormA's closing event:
VB Code:
e.Cancel = True
Me.Visible = False
This will cancel the unload of the form, and just hide it. This means that the variable you have that points to a FormA object is still valid, and you can just set the visible property to true to show it again.
Since FormA will stay in memory, when you are done with it for good, make sure you call it's close event.
-
Nov 1st, 2002, 01:11 PM
#4
Thread Starter
Lively Member
Thanks hellswraith. I should have thought using that closing event.
-
Nov 1st, 2002, 09:24 PM
#5
Why would you keep every form in memory when the user closes it?
I don't consider that a good design.
Just check if it has been disposed.
I answered a similar question in this thread
-
Nov 4th, 2002, 08:52 AM
#6
Thread Starter
Lively Member
Frans C, you are right in general. But in my case, it is kind of "background" form, i.e., i don't want it to be actually closed because i want to record all the values on the form's controls and don't want to define a group of variiables to record them.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|