|
-
Mar 2nd, 2011, 11:11 AM
#1
Thread Starter
PowerPoster
[RESOLVED] Hopefully an easy question
I have 2 forms, for example: FormA & FormB. The code in FormA might look like this:
Code:
FormB.Show()
Me.Hide()
When I use this code (VB6-like), it calls up FormB and then the program ends. If I comment out the me.Hide() it works, but FormA is still showing. I only want FormB to be showing.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Mar 2nd, 2011, 11:29 AM
#2
Frenzied Member
Re: Hopefully an easy question
If I do:
vb Code:
Me.Hide() Dim form As New Form() form.Show()
In a button click on the form (after it's loaded) then it works perfectly.
If you're doing it on the FormA_Load() then it's doesn't seem to do as well. Might have to pass
a ref of the form to the FormB in it's constructor and have a thread to check if FormA's handle has been created, if so invoke FormA's close method through a delegate maybe?
But you might see it flash and then go away : /. Only way I can think of doing it without googling it
Justin
-
Mar 2nd, 2011, 11:31 AM
#3
Thread Starter
PowerPoster
Re: Hopefully an easy question
Actually, the code is in a button_click event:
Code:
Private Sub cmdParts_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdParts.Click
frmMainMenu.Show()
Me.Hide()
End Sub
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Mar 2nd, 2011, 12:05 PM
#4
Re: Hopefully an easy question
check your application properties.. . I susepect that the option to control when the app end is set to the "When Startup Form Closes" .... so when you close form1, which I'm presuming is your startup form, it's firing off the app close. Change it to "When all forms are unloaded" or something to that effect.
Otherwise your code is fine.
-tg
-
Mar 2nd, 2011, 12:08 PM
#5
Thread Starter
PowerPoster
Re: Hopefully an easy question
That was it! I feel dumb, but I knew it had to be something simple like that. I just couldn't see it.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Mar 2nd, 2011, 12:09 PM
#6
Frenzied Member
Re: [RESOLVED] Hopefully an easy question
Mine are set to when the start form closes as well. Me.Hide() equates to Me.visible = false right?
Maybe try to put the Me.Hide() before the showing of the new form. I would be surprised if it made a difference, but maybe.
Justin
-
Mar 2nd, 2011, 12:09 PM
#7
Re: [RESOLVED] Hopefully an easy question
"When last form closes"
I have never turned on the framework either .
-
Mar 2nd, 2011, 12:10 PM
#8
Re: [RESOLVED] Hopefully an easy question
I forget about quite often initially too... that's why this time I recognized the symptoms and it was the first thing that came to mind. Funny how that works.
-tg
-
Mar 2nd, 2011, 12:13 PM
#9
Thread Starter
PowerPoster
Re: [RESOLVED] Hopefully an easy question
I'm glad it was so easy. I was beginning to question my move to VS2008 if something like this was throwing me.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
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
|