How can I make a form stay on top of my other forms?

R

Robin Tucker

How can I make my form stay on top of all the other forms in my application?
I don't want the form to stay on top in Windows as a whole, just be on top
of all the other forms in the given application instance.

Thanks,


Robin
 
G

Guest

Use a timer to keep checking Me.ActiveForm:
Private myForm As New Form1
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
If Me.ActiveForm Is Nothing Then
If Not (myForm Is Nothing OrElse myForm.IsDisposed) Then
myForm.TopMost = False
End If

Else
If Not (myForm Is Nothing OrElse myForm.IsDisposed) Then
myForm.TopMost = True
myForm.Show()
End If

End If
End Sub

I think maybe there is other way not to use timer.
 
S

steve

if i understand you right:
I had a similar question and this is the answer I got from Greg:

Dim f as new MyForm
If f.ShowDialog(Me) = DialogResult.OK Then
' do something
End If
f.Dispose()



I think myForm.showDialog(Me)
will also work

HTH
-steve
 
G

Guest

You can't work on other winForm if you use ShowDialog so that the application
is blocked by the dialog form.
 
R

Robin Tucker

Yes, these are modeless forms.

Rulin Hong said:
You can't work on other winForm if you use ShowDialog so that the
application
is blocked by the dialog form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top