We all know that .ShowDialog() is great but sometimes You want to show user some window and keep program running. (.ShowDialog() freezes code execution in method as we all know)
Let's say You have this scenario that You want to have form that will not loose focus but at the same time You want to do some work after window is shown. Of course .ShowDialog() is not an option because work after it will not be done before You close the window. So how can You acomplish this ?
I've searched on forums and some solution (especially with Deactivate/Activate) simply don't work. So how can You do this ?
In Your form class, override
and place focusing call inside it. So it looks like this:
protected override void OnLostFocus(EventArgs e)
Simple but works.
OK. In some cases (and i don't know exactly why) you should do
protected override void OnDeactivate(EventArgs e)