Reputation: 87
i have my main form and it has a button that will show the second form and it enabled = false the first form.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Form2.Show()
Me.Enabled = False
End Sub
when you click the button on the second form it will go back to the first form and it will enabled = true.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.Hide()
Form1.Enabled = True
End Sub
what my problem is that when i click "back" button the second form is gone but the first form is sent at the back of the current window, you still need to minimize that particular window to see the form 1 again.
Upvotes: 1
Views: 1143
Reputation: 5393
Have you tried making the second form a "modal" form, with ShowDialog
?
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If Form2.ShowDialog() = Windows.Forms.DialogResult.OK Then
MsgBox("OK!")
Else
MsgBox("Cancelled :-(")
End If
End Sub
End Class
Public Class Form2
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.DialogResult = Windows.Forms.DialogResult.OK
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.DialogResult = Windows.Forms.DialogResult.Cancel
End Sub
End Class
Upvotes: 1