|
-
May 26th, 2003, 07:46 PM
#1
Thread Starter
Lively Member
Question about showing and hiding forms
Okay this might seem kind of a dumb question, but i cant seem to figure it out...
i have this code in form 1:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim Form2 As New Form2()
Form2.Show()
End Sub
and this code in form 2:
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim form1 As New Form1()
form1.Hide()
End Sub
The problem is that Form2 will show, but it will not hide form1 when it loads, what can i do to fix this, i have tried everything i can think of.
-
May 26th, 2003, 09:27 PM
#2
PowerPoster
http://msdn.microsoft.com/library/de...adingtonet.asp
Required reading.
What you are doing is creating a new instance of form1 in your form2 code. This isn't affecting the instance that is already created. In order to do form1.hide, you need to have a reference to the already created form1. You can pass in a reference through the constructor of form2, or you can do what that link says to do.
-
May 28th, 2003, 07:19 AM
#3
Fanatic Member
I think you can just set the visibility of form1 in the designer to false. If not you can use Me.Hide() or Me.Visible() = False in Form1 load event. The previous post hit the nail on the head.
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
|