Click here to Skip to main content
15,846,144 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
First of thanks to all of you for providing me help on my previous two question.

But now have another problem.
Here it is ;

I am making project in c# and wants to make one form disable on linklabel click event and open another form at the same time .
Once the work of second form is over and i closes that form on button click and i want previous form to become enable again.


In short i want to make a popup window which disables entire screen except that particular window and when work is over and i closes that window screen gets activated.


Well, disabling the entire desktop is just plain bad manners. The act of opening up another form in essence prevents the user from doing anything in previous forms of a given application until the current form is closed. There's no need for extra processing to do what you want to do.

You *could* however HIDE the first form, and then re-show it when the other form is dismissed, something like this:

private void button_Click(...)
    Form2 form2 = new Form2();
    form2.Closed += new EventArgs(form2_Closed);
    this.Visible = false;

private void form2_Closed(...)
    this.Visible = true;
Share this answer
Dr.Walt Fair, PE 15-Aug-11 18:46pm    
Yes, disabling the whole desktop will create problems in the long run, but I'll never tell how I know. :) Hiding is one option, but if anything goes wrong, you could have a hidden form and no way to do anything about it.

I suppose it depends on what could go wrong in the OP's particular case, but I'd probably opt for using a dialog rather than a plain form.
sangaur 16-Aug-11 1:10am    
Thank You very much
use the Form2.ShowDialog() method.
For more information see:[^]
Share this answer
Dr.Walt Fair, PE 15-Aug-11 18:47pm    
Yes, the dialog will affect only the active application and I can say from experience that disabling the entire desktop is just asking for problems!
sangaur 16-Aug-11 1:09am    
thank you i appreciate ur help and it really worked as per requirement.
u can use these two routines :-

1. form1.Hide();
2. form2.Show();
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900