-
c The difference between the non-modal form show() and the modal form showdialog().
Dialogs are either mode-mode or mode-free. Modal dialogs, which must be closed (hidden or uninstalled) before you can continue to work on other parts of the application. For example, if a dialog box requires you to click OK or Cancel before you can switch to a different form or dialog box, it is modal.
1. How to call.
Any form, a class that derives from the base form, can be displayed in two ways.
Non-modal forms.
from qform=new form();
Modal form. form qform=new form();
1. Differences in control.
It's okay to go back as soon as you create a new form (not a mode) and without establishing any relationship between the currently active form and the new form, i.e., closing (or minimizing) an existing form while keeping the new window or closing (or minimizing) a new window while keeping the existing form.
Create a modal form, i.e. the original form can regain control only when the new window is closed. That is, if you do not close the new window, you will not be able to do anything with the original active window. Minimizing and restoring the new window will be performed along with the original window, but the closing of the new window will have no effect on the original window.
It is important to note that in either case, as soon as the main form is closed, or the main program ends, all forms will be closed, regardless of whether it is modal or non-modal.
-
Set a public static variable and set the value of the variable to true in load when the window opens. When the window is closed, set the value of the variable in the closing parameter to false. To determine whether the window is open, just read this variable.
-
It's very simple, define the global object from2 f2=new from2 ().
Determine if if(f2==null) exists
Actually, there is a simpler idea.
This is the one that calls the form object. show();And. hidden();method when you want this form to be displayed is calledshow();
To hide the form (equivalent to closing the form) and not show it, call .hidden();Method.
-
1. Find the button on the page where we want to add this command.
2. Then we find the appropriate place to write the click event, and the others can also be.
3. At this time, we can use the messagebox class to pop up prompts.
4. The messagebox class will return an ok value of dialogresult after the execution is completed.
6. If it is not established, we can give a corresponding response, or we can not write other operations.
-
This can't be provided, you can find an event in the form properties, called closing, which is triggered before the form is closed, and add ** to this event.
-
Write **:in the formclosing event of the window
private void form1_formclosing(object sender, formclosingeventargs e)}
-
Add dialogresult dr; dr = "Are you sure you want to quit? ", "Tips", ,if (dr == else
-
There is the formclosing event in the form, which is run when the form is closed. If you want to cancel the operation of an event, you can cancel the event by writing it in the event, that is, the event will not be executed. Therefore, when you want to close the form, a window will pop up to prompt whether to close the form, if you choose not to close, then you can write it, ** as follows:
In the formclosing event: if ("Sure to quit? ", "Tips", ;
The content in the above if is,Pop up a prompt box,The prompt box has ok and cancel two buttons,When you press the cancel button, the condition is valid.。。 I hope the above information is helpful to you. ^
-
Add dialogresult dr;
dr = "Are you sure you want to quit? ", "Tips", ,if (dr ==
else
Go and see my article, I myself am also this problem, and I wrote a post by myself when I saw that there was no article on the Internet that really solved the problem, and I didn't need a grid machine >>>More
Background to the development of the offside rule.
The offside rule was formalized in the football rules of 1874. However, the offside rules at that time were very different from the offside rules now. At that time, it was stipulated that: >>>More
In C++, vector is used as a container, and its function is to store variables of struct type. Here's how vector might be used: >>>More
The easiest way to do this is to create a constructor with a string parameter in form2, and then generate a form2 form. >>>More
Appears memory can not be"read"There are many reasons, try to use the following methods to patiently eliminate them. >>>More