Reputation: 2818
I currently have a problem with forms here.
Whenever some process is ongoing, I have a progress dialog that should popup, but when I click the "X" button of the window/form behind my progress dialog, it will be dismissed and the ongoing operation is cancelled.
How can I prevent that from happening? Should I have to disable my whole form behind my progress bar? and how can I do it?
p.s. I have tried this and this and this but NONE of them seems to work in my application. T__T
Upvotes: 1
Views: 632
Reputation: 2214
You should show the progress bar as modal dialog, please check whether this answer work for you javasript like model window on winform
HTH.
Upvotes: 0
Reputation: 152556
Start the form using Form.ShowDialog()
instead of Form.Show()
. That will disable the background form (actually any other form in the process) until the form you are showing closes. As an added benefit you can have the form return a value (e.g. Cancel, OK, Yes, No, etc.) in case any action needs to be taken as a result.
Upvotes: 3
Reputation: 1258
Not actually the answer you might be expecting, but you could handle the Form.FormClosing
event, setting e.Cancel = True
This won't disable the Close button, but will make your form remain open in this case.
See more at: http://msdn.microsoft.com/en-us/library/system.windows.forms.form.formclosing.aspx
Upvotes: 1