-
You can pass the main window as a parameter to a child window.
**As follows: Main Window:
public partial class frmmain : form
public static frmmain f0 = null;Used to refer to the main window.
public frmmain()
initializecomponent();
f0 = this;Assignment.
private void button1_click(object sender, eventargs e)
new frmcx().show();
Sub-window: Public Partial Class FRMCX : form
public frmcx()
initializecomponent();
private void frmcx_formclosing(object sender, formclosingeventargs e)
The main window is displayed.
-
Your main window is from1, if so, it's new from1()show();That's it, what you do is a winfrom program, and the name of the form is what you call from2 and from1, so the class name of your form is from2 and from1, and you can instantiate the object with the class, so you understand?
-
Add a member variable of type form1, p frm, to form2
Make = form1
Then p
-
Directly under the button in form2.
form1 f3=new form1();
Then you click on the button form1 and it comes out.
-
According to the upstairs method, you can call show by passing form1 to form2, but in fact, this is not a good method, if you forget to return to form1 in form2, and close form2 directly, then form1 will permanently reside in memory (unless closed with task manager), it is better to use mdi, or make it in the form of control loading.
-
Constructor.
Button Click event in form1: private void button1 click(object sender, eventargs e).
form2**:
form f1 = new form1();
form2 construction.
public form2(form1 firstform) form2 button click eventprivate void button1 click(object sender, eventargs e).
-
Pass form1 as a parameter to form2, for example, when displaying form2;
When clicking on the button: ;;
-
Well, that's fine, form 1:
public form1()
Button event for Form 1.
private void button1_click(object sender, eventargs e)
Form 2: form1 f1 = null;
public form2 (form1 f) Close button event for Form 2.
private void button1_click(object sender, eventargs e)
Give it a try
-
When you open a new form2, you will hide the original form1
form2 fm = new form2(this);It feels like it's actually a parameter to pass in and pass the current main form to enter.
Hide this window now.
A new window appears.
When closing a new form2, the original form1, public partial class, form2: form, is displayed
Add form2 formclosing event to form2.
private void form2_formclosing(object sender, formclosingeventargs e)
I promise that I can, because I just checked the information and got the result like this, Meizizi
-
Well. I see what you're talking about.
Let's take an example.
For example, there are two forms, form1 and form2
To do this, click a button in form2 to make form1, which has been hidden, appear.
It can be done like this.
Add a public static form variable to class form1. Make him equal to the current form:
Here's how: public static form f;
Then in the constructor of form1 it is written like this:
public form1()
Next. You can hide or show form1 by manipulating it in class form2.
If there's anything you don't understand, you can ask me. Hey.
-
Change its disable property to make the already hidden form visible
-
It would be nice to change the visible property of its widget to true.
-
It should be written like this:
Parent form's key event.
form1 f = new form1();
dialogresult d = ;
if(d ==
true;The key event of the subform.
form1 is changed to its own parent form name.
form2 is changed to its own subform name.
It's a habit to come back and like it.
-
You can use the following methods to show the parent form that has been hidden:
Use the modal dialog showdialog().
Returns = dialogresultValue;
Main form keys**:
form1 f = new form1();
dialogresult d = ;
if(d == dialogresult.value) = true;
-
It's very simple: write the parent's visible=true in the child form's closing event; That's it,
-
In the close event of the form, the open parent form event is raised, which causes the form to reappear in the event.
-
Parent window:
form form2 = new form():
this;Subwindow: Change the capitalization yourself.
-
In the closing event of the subform,;
-
Set the visible property of the form to true
-
Upstairs is OK, and you can set the visible property of the form to true.
-
When the form loads, execute; methods or use attributes; , so that the form can be hidden when the program starts.
-
Is it a landing form?
Perform the close statement after hiding and waiting for the subform to be used.
form2 frm2=new form2();
Hide the parent form first.
Display the subform.
Wait for the subform to be used and then execute the close statement;
-
Eject the child form while hiding the parent form.
Subform. fm=new subform();
-
1. The first solution:
Form A itself controls whether it is hidden or not. Add the following ** to the button event.
false;
form2 f2 = new form2();
Not available here;
true;After form2 is closed, the second solution of this statement 2 and the second solution will be executed
Form B controls whether A is hidden or not.
This requires form1 to pass itself as a parameter to form2, which is controlled by form2 execution.
Define a new display method in form2.
from fm = null;Used to store form1 variables public void showme(form f)fm = f;
false;Hide form1.
show();
Add ** to the formclose event in form2.
true;Let form1 show.
Finally, there is the ** in the button event of form1.
form2 f2 = new form2();
Note: There are other ways to solve this problem. Such as the use of event processing mechanisms, etc.
-
There are two ways to do this.
One is to hide, it seems to be written like this, anyway, it's a method that starts with h, this is to hide the form, and when you close the form b, you need to show the form a
Just use it...
Another way to do this is to close form A and open form b, which is then in the startup settings.
Plus when when A is turned off, when B is turned off, then when B is closed, it is still used to open A....
-
Use the event to close the window.
Take a closer look.
When window B closes.
form a=new form();
Because A is the main window.
So it is hidden.
-
You can write it in the back.
The fastest - the answer is answered.
If you want to do it for a short time, you can do the rookie task - 20 Fortune. >>>More
int a =;
int b =; >>>More
Is your "2012-07-23" a field? If you can directly use the substitution function to replace the year, month and day with "-", it will save trouble.
Your anomaly was triggered, but it was eaten.
Because the using statement is actually try....Finally, your ** is equivalent to. >>>More
First of all, it is necessary to understand what a binary tree is (and I guess the subject also understands). >>>More