Question : How do I return focus to a form

Hello

I am having a real problem getting focus back to a form.

--------------
Form A.ShowDialog
+ code
Form B ShowDialog
+code
B.Visible =False
--------------

But when Form B disappears, Form A is not the focus.

Any ideas?

Answer : How do I return focus to a form

Another alternative to WaitForExit() is to turn ON EnableRaisingEvents() and then subscribe to the Exited() event.  Also, instead of hardcoding the path to Excel (which could be installed anywhere) just pass the name of the file and Excel will be found for you:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Button1.Enabled = False

        Dim myProcess As New System.Diagnostics.Process
        myProcess.StartInfo.FileName = "C:\oldf\MYEXCEL\calconepercentile.xls"
        myProcess.EnableRaisingEvents = True
        AddHandler myProcess.Exited, AddressOf myProcess_Exited

        myProcess.Start()
    End Sub

    Private Sub myProcess_Exited(ByVal sender As Object, ByVal e As System.EventArgs)
        Button1.Enabled = True

        ' ... more code here ...

    End Sub
Random Solutions  
 
programming4us programming4us