|
-
May 22nd, 2002, 08:30 AM
#1
Thread Starter
New Member
VB.NET Windows Form exit problem
Okay here's the deal,
I somehow keep losing the ability to naturally close my Windows Form. The user can click on the "X" until the cows come home, they can right click and go to "Close" but it will not work. You have to terminate it from the task manager, or I have to add another button on my form that triggers the "END" command.
Here are a few of the ways I have caused this problem:
1. A login user control is in a tab control;when the user clicks on the "Login" button, the system logs the user in and that tab is destroyed and replaced by the tabs available to the user within the application. I can login, logout and do all kinds of stuff but when I destroy the login page I lose the ability to unload.
...I got around this by switching to a tab strip and I was able to remove my user controls from my main form's control collection.
2. A customer search form is on a sub frame. When the user selects a customer a series of events are triggered to bring up that user's information. The search form is destroyed and the user's account information becomes visible.
With this the code didn't work if I did this
*SeachForm is the object I'm getting rid of*
Me.Controls.Remove(SearchForm)
SearchForm.Dispose()
SearchForm = Nothing
But it did work when I just did this
SearchForm.Dispose()
Me.Controls.Remove(SearchForm) *This line became optional*
SearchForm = Nothing
3. Now one I'm stuck on. On the search form if the user double clicks on a record it calls a method to do the unloading of all of that stuff - this works fine. I call the same method from a button and I hit this problem. I don't know of a way around it yet.
Can someone PLEASE tell me why this is happening period? I'd like to know how to prevent this problem.
If you need more information, just let me know.
Thanks in advance,
-James
-
May 22nd, 2002, 09:40 AM
#2
Thread Starter
New Member
Fixed, but WHY?
Okay, now #3 was solved by adding
Me.Controls.Clear() to the dispose method of the search form.
I checked, and this does NOT clear up the problem with #2, I still have to use the other solution I came up with.
To check #3 better I placed a label and a button on the search form, I gave them both the same event handler that ran the code:
Me.Dispose()
When I clicked the label everything would work fine, when I clicked the button I would encounter the problem. When I added
Me.Controls.Remove(CType(sender, Control)) above the Me.Dispose() method, things exited fine.
What the heck is up with this :
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
|