Home > Net >  In c # how to minimizing the child form independent
In c # how to minimizing the child form independent

Time:10-18

I set up A main Form, the main Form is set above the function of each module, each function module is A child Form, child Form A of the Form through the new Form shows A child Form B, I minimize the Form B, Form A and follow all minimize the main Form, very upset about it, would you please tell me what the method you Daniel, minimize the Form B just minimize the oneself, to minimize the task bar then click can restore again, ask the great spirit action ah, thank you

CodePudding user response:

I don't use local VS2015 LZ said this problem, this is my local code
 
//Form1. Cs:
Private void Form1_Load (object sender, EventArgs e)
{
FormA fa=new FormA ();
Fa. MdiParent=this;
Fa. The Show ();
}
Private void InitializeComponent ()
{
Enclosing SuspendLayout ();
//
//Form1
//
Enclosing AutoScaleDimensions=new System. Drawing. SizeF (6 f, 12 f);
Enclosing AutoScaleMode=System. Windows. Forms. AutoScaleMode. The Font;
Enclosing ClientSize=new System. Drawing. The Size (554, 351);
Enclosing IsMdiContainer=true;
This. Name="Form1";
This. The Text="Form1";
Enclosing the Load +=new System. EventHandler (enclosing the Form1_Load);
Enclosing ResumeLayout (false);
}
//FormA. Cs:
Private void button1_Click (object sender, EventArgs e)
{
FormB fb=new FormB ();
Fb. MdiParent=MdiParent;
Fb. The Show ();
}

CodePudding user response:

Added to the second method is the system automatically generated, I just put the main form of IsMdiContainer attribute set to true

CodePudding user response:

Your way is much document form on the second floor

CodePudding user response:

Your code has a problem, child form the default will only shut down, according to the main form closed won't appear what you said at the same time to minimize the situation

CodePudding user response:

reference 1st floor lyq8376 response:
I don't use local VS2015 LZ said this problem, this is my local code
 
//Form1. Cs:
Private void Form1_Load (object sender, EventArgs e)
{
FormA fa=new FormA ();
Fa. MdiParent=this;
Fa. The Show ();
}
Private void InitializeComponent ()
{
Enclosing SuspendLayout ();
//
//Form1
//
Enclosing AutoScaleDimensions=new System. Drawing. SizeF (6 f, 12 f);
Enclosing AutoScaleMode=System. Windows. Forms. AutoScaleMode. The Font;
Enclosing ClientSize=new System. Drawing. The Size (554, 351);
Enclosing IsMdiContainer=true;
This. Name="Form1";
This. The Text="Form1";
Enclosing the Load +=new System. EventHandler (enclosing the Form1_Load);
Enclosing ResumeLayout (false);
}
//FormA. Cs:
Private void button1_Click (object sender, EventArgs e)
{
FormB fb=new FormB ();
Fb. MdiParent=MdiParent;
Fb. The Show ();
}


Thank you, is my own program error, can ask you A question, do you understand the multiple knapsack problem, I have N items, the weight of each item and the value is 1, the biggest desirable quantity each item is an array A [N], each item can not take, I want to output all the feasible solutions (including each item how much), are looking forward to your reply, thank you thank you, all give you, I'll add

CodePudding user response:

Arguably not, whether you use formB. Show (this), get rid of this

CodePudding user response:

//using multithreading can solve your problem, because I also meet you the same question, development should be the request of the customer, this email!
Using System;
Using System. Collections. Generic;
Using System.Com ponentModel;
Using System. The Data;
Using System. Drawing;
Using System. Linq;
Using System. The Text;
Using System. The Threading;
Using System. Windows. Forms;

The namespace FormA
{
Public partial class FormA: Form
{
Public FormA ()
{
InitializeComponent();
}

Private void button1_Click (object sender, EventArgs e)
{
Thread the Thread=new Thread (threadPro);
Thread. The Start ();
}
Private void threadPro ()
{
MethodInvoker MethodInvoker=new MethodInvoker (ShowFormB);
The BeginInvoke (methodInvoker);
}
Private void ShowFormB ()
{
FormB frmB=new FormB ();
FrmB. The Show ();
}
}
}
  •  Tags:  
  • C #
  • Related