Hi, I have form1, and second form2

When I call second form2, form1 is disabled for any interaction.

 customer.Show()
        Me.Enabled = False

Close button on form2 code is

Private Sub Closebutton_Click(sender As Object, e As EventArgs) Handles Closebutton.Click
        Me.Close()
        Form1.BringToFront()
        Form1.Enabled = True
End Sub

As you can see, I want to enable form1, and to call form1 to front. However, form1 has lost under other opened programs, and I can get it to fron by clicking on TaskBar.

It would be improper for any app to force itself to be the active application.

Even though Windows does this all the time.

commented: "Hey, hey, look at me!" Also, nice to read that someone else calls Windows an app. +15

Another way to go is to make form2 a dialog form. This will make it modal and since it remains part of form1, form1 will still be on top but inaccessible while form2 is active.

commented: Reading about codes I run into Dialog and Modal forms in VB. Thanks. +2

to bring your child form top
dim obj as new
obj.mdiparent=
obj.shoe

Maybe using show and hide is abetter way to deal with the issue.

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Form2.Show()
        Me.Hide()
    End Sub
End Class

Public Class Form2
    Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.Close()
        Form1.Show()

    End Sub
End Class
commented: Thanks man. This is behavior I was looking for. +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.