Hi
Is there a way in C#, to open another form as modal, without blocking the application (able to open and use secondary forms), and without using threads?
So have 3 forms
Use Form 1 to open Form 2 modally, while still able to use Form1 to open form 3 and use it as normal, without using threads?
Or If you have tabs, and you want to open a messagebox modally, in one tab, but be able to go back and forth between tabs and use them as normal, while in say tab x, a modal form is opening. Do this without threads!
Also : In another topic: How to remove a project from the list in VS2005 that you used recently? (The Start page list).
Thanks
-
-
I don't think you understand what a modal dialog is.
-
Yep. If you want it to be modal, it has to block the application because that's the definition of modal.
If you want a dialog that pops up and stays on top while allowing you to continue using the other window, just create and show the form normally, like
Form f = new Form1();
f.show()
and in the form's properties, set TopMost to true. -
A modal form is that form that will hald application execution until that form is disposed of. Its basically, asking the application to stop doing anything, until the modal condition is gone. It sets other forms to Enabled = False.
So I do understand what modal is. What I am asking is, a way around that , by scoping it down at the control level. So stop processing control -specific events, until the top most form is disposed of, but not the entire application. So lower scope to the control level. Is it possible?
Edit: As in the Tab control, in one tab have a form open as if it was a modal form, while being able to go to another tab and doing stuff there. -
So probably you're asking to disable all the controls on the main form...
for each (Control ctrl in this.Controls)
{
ctrl.Enabled = false;
}
P.S.: I'm not using "this.Enabled = false", because I'm not sure what effect will it have when a child window is opened. But you may use that if tested and find no problem. -
Why not just disable "Tab A" before displaying your "topmost" dialog, then enable it again after the dialog got closed?
-
PolymorphicCode wrote:Can do this in C# without use of Threads ?
C# probably not. ie Bad design choice (using a modal Dialog for this).
But in C/C++, oh yeah...
Check out [Raymond's series on modality].I'll let you know if there's anything about .NET in it, when I'm done reading it.
Edit:
There's nothing related specifically to .NET in that series. But there are some good points raised in the comments about the design choices of modality. eg Instead a modal dialog, what about disabling the controls within the tabset (gray-out), and then adding/showing/drawing something in place of said dialog. A sidebar, or the like.

Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.