C
cr113
Suppose you have Button1 on Form1. If the user clicks Button1, I want
to show Form2 modelessly. If Form2 is already open I just want to
redisplay it, not open a new window. Thru trial and error I came up
with the following code. Is there a better way to do this?
Public Class Form1
Dim objForm As Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If (IsNothing(objForm)) Then
objForm = New Form2
objForm.Show()
Else
If (objForm.Created) Then
objForm.BringToFront()
Else
objForm = New Form2
objForm.Show()
End If
End If
End Sub
End Class
to show Form2 modelessly. If Form2 is already open I just want to
redisplay it, not open a new window. Thru trial and error I came up
with the following code. Is there a better way to do this?
Public Class Form1
Dim objForm As Form2
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If (IsNothing(objForm)) Then
objForm = New Form2
objForm.Show()
Else
If (objForm.Created) Then
objForm.BringToFront()
Else
objForm = New Form2
objForm.Show()
End If
End If
End Sub
End Class