-
The overall idea is to set both the A and B forms as global variables, so that they can access each other.
For the specific method, you open it first and change the things in the prgram class to something like this.
public static form1 form1;
public static form2 form2;
static void main();
form1 = new form1();
Of course, you can't run two forms in one program, and the other one needs to be showdialog.
-
It's easy to do. You can do this.
Declare an instance of form B in form A.
Then when you show out form B, call its show method directly, don't use showdialog (or you won't be able to click the button on form A).
Calling the close method of the instance of b in the event of a button... Well.
-
Then you need to get a reference to form b in form a, which is the thing before the new formb() thing, e.g. formb fb=new formb();
If Form B is created in A, it's simple and straightforward;
If not, you have to pass the reference with an argument and then execute close
-
LZ wants to close Form B during the button click event of Form A, is there still a button to open Form B?
This is because the program entry cannot allow two forms to be displayed at the same time.
-
Change the two forms to public so that it is convenient to use, hehe. But the security is a little worse.。。
-
Whichever form you want to close, use a new object and call its close() method with that object.
-
Then in form A, a new instance of form b is written, and in window A, it is written;
-
1. First of all, we open the properties of the sub-window, click on the "lightning icon (framed in the picture below)" to find the formclosing (or formclosed) event, and double-click.
2. In the gameui formclosing event**.
<>4、;If you just close the current window, you can't exit the program if it's not the main form, and if you have a managed thread (not the main thread), you can't exit cleanly.
5、;Force all messages to abort and exit all forms, but if there is a managed thread (not the main thread), it will not be able to exit cleanly.
6、;Forcibly aborting all messages on the calling thread also faces the problem that other threads cannot exit correctly.
7、;This is the most thorough way to exit, no matter what thread is forced to quit, and the program ends cleanly.
I don't know if net has this kind of control or has the function itself, if you want to write it yourself, it is to detect whether the program form is outside the screen, that is, whether the y coordinate is less than 0 and so on; It will be displayed if the mouse cursor is moving over it.
Your form2 constructor should be overloaded once: it should pass the textbox as an argument and it becomes: >>>More
Check this out. <>
You can also knock ** yourself. >>>More
clrscr is a standard library function for C, not a standard library function for C++. >>>More
It's textbox, right? textbook?
double somedouble; >>>More