noidea noidea - 6 months ago 14
Vb.net Question

how to put winform behind all open programs vb.net

I'm calling a vb.net exe from a program in java, and i want it to stay behind all of the already opened programs.

I read that you can kinda bring to front with

TopMost
set to
true
, but i find no way to put it in the back.

There's some workarounds, like
setvisible=false
the previous form and setting to
true
after that, but that isn't quite good with my application. Thank you!

Answer

Calling the form's SendToBack (Inherited from Control) method from the Shown event handler is the key. Calling it from load for example, won't do anything since the window isn't "ready" yet anyway.

Private Sub Form1_Shown(sender As System.Object, e As System.EventArgs) Handles MyBase.Shown
    SendToBack()
End Sub