While I agree with everyone, this is no-nice behavior, here is code:
[DllImport("User32.dll")]
public static extern Int32 SetForegroundWindow(int hWnd);
SetForegroundWindow(Handle.ToInt32());
Update
David is completely right, for completeness I include the list of conditions that must apply for this to work (+1 for David!):
- The process is the foreground
process.
- The process was started by the
foreground process.
- The process received the last input
event.
- There is no foreground process.
- The foreground process is being
debugged.
- The foreground is not locked (see
LockSetForegroundWindow).
- The foreground lock time-out has
expired (see
SPI_GETFOREGROUNDLOCKTIMEOUT in
SystemParametersInfo).
- No menus are active.