Search code examples
c#winforms.net-2.0focus

Form's lost focus in C#


This may be a simple C# question but I need a solution.

I have two forms, form1 and form2, with form1 having a button. On the click of the button, I want to show form2. When form2 looses focus I want to hide it (form2). How can I do this? I tried to subscribe to the LostFocus event of form2, but it isn't working.

Please help me with this.

Note -- I use .Net 2.0


Solution

  • Use the Deactivate event handler