in vb 2005. im making a program that when you start it it has a window with just buttons in it. when you click one of the buttons the window will disply a new window. i need it to be just one window and not multiple windows when i cick the buttons on the first page
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim f1 As New Form1 f1.StartPosition = FormStartPosition.Manual f1.Location = Me.Location f1.Size = Me.Size f1.WindowState = Me.WindowState f1.Show() Me.Close() End Sub End Class
Project + properties, Application tab, scroll down, Shutdown mode = "When last form closes".
Public Class Form1 Private mForm2 As Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If mForm2 Is Nothing Then '--- Form doesn't yet exist, create a new one mForm2 = New Form2 AddHandler mForm2.FormClosed, AddressOf Form2_Closed mForm2.Show(Me) End If mForm2.Focus() End Sub Private Sub Form2_Closed(ByVal sender As Object, ByVal e As FormClosedEventArgs) mForm2 = Nothing End Sub End Class
Public Class Form1 Private mForm2 As Form2 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If mForm2 IsNot Nothing Then mForm2.Close() mForm2 = New Form2 AddHandler mForm2.FormClosed, AddressOf Form2_Closed mForm2.Show(Me) End Sub Private Sub Form2_Closed(ByVal sender As Object, ByVal e As FormClosedEventArgs) mForm2 = Nothing End Sub End Class
mutipe pages?
WII
Amde
Hi,
I think this user is after using a Panel for controls instead of a new Form so that everything stays on one FORM or 'window' as Timmy0614 puts it.
Unless you can have a child Form within a Form
Like a child scrollable window within a HTML browser.
Regards,
S_DS
syhzaidi
Vlad Shimov
AdrianG
vanu
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim f1 As New Form1
f1.StartPosition = FormStartPosition.Manual
f1.Location = Me.Location
f1.Size = Me.Size
f1.WindowState = Me.WindowState
f1.Show()
Me.Close()
End Sub
End Class
Project + properties, Application tab, scroll down, Shutdown mode = "When last form closes".
Chimme
Public Class Form1
Private mForm2 As Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If mForm2 Is Nothing Then
'--- Form doesn't yet exist, create a new one
mForm2 = New Form2
AddHandler mForm2.FormClosed, AddressOf Form2_Closed
mForm2.Show(Me)
End If
mForm2.Focus()
End Sub
Private Sub Form2_Closed(ByVal sender As Object, ByVal e As FormClosedEventArgs)
mForm2 = Nothing
End Sub
End Class
febwave
Wayne.C
Public Class Form1
Private mForm2 As Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If mForm2 IsNot Nothing Then mForm2.Close()
mForm2 = New Form2
AddHandler mForm2.FormClosed, AddressOf Form2_Closed
mForm2.Show(Me)
End Sub
Private Sub Form2_Closed(ByVal sender As Object, ByVal e As FormClosedEventArgs)
mForm2 = Nothing
End Sub
End Class
dbaf