PDA

Click to See Complete Forum and Search --> : forcing form infront[Resolved]


Techno
Jan 31st, 2006, 04:28 AM
Hi

Was wondering if it is possible in C# to make a form stay infront of another form until they press a button or close the dialog properly?

For example, in MessageBox's - if you try to click on the form behind the MessageBox, it will not allow you to until you click the appropriate button on the MessageBox.

Many thanks!

Phill64
Jan 31st, 2006, 04:30 AM
set its TopMost property to True, and use it as a dialog .ShowDialog

Kasracer
Jan 31st, 2006, 04:32 AM
Just use ShowDialog(). If you use TopMost as well, they won't be able to see some other applications because your form will be in their way (since it puts it at the top of all windows) which is very annoying.

Techno
Jan 31st, 2006, 05:00 PM
ok ill give the top most a shot and see what happens.

anything else?

Techno
Jan 31st, 2006, 05:10 PM
Ok, that top most is cool but I wanna go a step further.

When the user clicks on the previous/behind form from this top most form, i dont want them to use/click the behind form at all - like a message box.

I also do not want to hide/show the main form - pretty much I would like it the way it acts on a MessageBox :)

Techno
Jan 31st, 2006, 05:35 PM
ShowDialog(); seems to do the trick

Kasracer
Feb 1st, 2006, 04:10 AM
I would still recommend not using TopMost. It's not very user friendly and I tend to uninstall anything that does that because I like to work in multiple applications.

Also, please mark your thread as resolved.

jmcilhinney
Feb 1st, 2006, 04:15 AM
ShowDialog and TopMost are intended for two quite different purposes. ShowDialog creates a modal dialogue, which is what it sounds like is needed here, where the user cannot access the calling form until the dialogue is dismissed. Using the TopMost property is good when you need the user to be able to see your application while working in another, like Task Manager. Like Task Manager again, it is always polite to provide an option to turn off that behaviour that would set your Form's TopMost property back to False.