VB .NET 2008 - Application lose focus on closing a modal Form

  • 12 years ago

    Hi all,

    I have a problem with application losing focus on closing a modally opened form (I am using ShowDialog to show the form). If I run the application and then keep opening and closing the forms it works fine, but after running the application if I open or set focus to any other application opened (eg word, outlook, Internet explorer etc) on my computer and then go back to my application and close the modal form it closes the form and instead of showing the owner form the whole application loses focus and the last application I was in on my computer shows up. I am using the Visual Studio Express edition (The free version). Is it because of that? Below is my code to open the form

     Dim frm as New Form1
     frm.ShowDialog(Me)
     frm.Close
     frm = Nothing

    In the Form1 I added a close button and the code I have in the click event is Me.Hide
    I was reading through some forums and one person said add Me.Owner.Focus() before Me.Hide and still it does not work.
    Any help is appreciated.
    Thanks,
    Rakesh

     

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Brevity is the soul of wit” - Shakespeare