一个非常简单的问题(在线等待) 方法1 : 看书方法2: 去www.projcodes.com下载例子 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1; Form1 newMDIChild= new Form1 () ; newMDIChild.MdiParent = this; newMDIChild.Show();2. Form2 frm2=new Form2(); frm.Show();可以给分了吧 假如Form1 为父窗体,Form2、Form3为子窗体在Form1上用((Form2)this.MdiChildren).Width这是从父窗体调用子窗体在Form2上用((Form1)this.MdiParent).Width这是从子窗体调用父窗体如果是多个窗体的话就用foreach循环找一下类型子窗体和子窗体之间的调用也和上面的差不多。 1.Form1 newMDIChild= new Form1 () ; newMDIChild.MdiParent = this; newMDIChild.Show();2.Form2 frm2= new Form2();frm2.Show(); 随便写了一个,你看看,3个窗口我分3张贴using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;namespace test{ /// <summary> /// Form2 的摘要说明。 /// </summary> public class Form2 : System.Windows.Forms.Form { private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox t1; private System.Windows.Forms.TextBox t2; private System.Windows.Forms.TextBox t3; /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public Form2() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label(); this.t1 = new System.Windows.Forms.TextBox(); this.t2 = new System.Windows.Forms.TextBox(); this.t3 = new System.Windows.Forms.TextBox(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(24, 40); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(66, 14); this.label1.TabIndex = 0; this.label1.Text = "Form1.Text"; // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(24, 80); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(66, 14); this.label2.TabIndex = 1; this.label2.Text = "Form2.Text"; // // label3 // this.label3.AutoSize = true; this.label3.Location = new System.Drawing.Point(24, 120); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(66, 14); this.label3.TabIndex = 2; this.label3.Text = "Form3.Text"; // // t1 // this.t1.Location = new System.Drawing.Point(96, 40); this.t1.Name = "t1"; this.t1.TabIndex = 3; this.t1.Text = "textBox1"; this.t1.TextChanged += new System.EventHandler(this.t1_TextChanged); // // t2 // this.t2.Location = new System.Drawing.Point(96, 80); this.t2.Name = "t2"; this.t2.TabIndex = 4; this.t2.Text = "textBox2"; this.t2.TextChanged += new System.EventHandler(this.t2_TextChanged); // // t3 // this.t3.Location = new System.Drawing.Point(96, 120); this.t3.Name = "t3"; this.t3.TabIndex = 5; this.t3.Text = "textBox3"; this.t3.TextChanged += new System.EventHandler(this.t3_TextChanged); // // Form2 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(292, 273); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.t3, this.t2, this.t1, this.label3, this.label2, this.label1}); this.Name = "Form2"; this.Text = "Form2"; this.Load += new System.EventHandler(this.Form2_Load); this.ResumeLayout(false); } #endregion private void Form2_Load(object sender, System.EventArgs e) { this.t1.Text=this.ParentForm.Text; this.t2.Text=this.Text; this.t3.Text=this.ParentForm.MdiChildren[0].Text; } private void t1_TextChanged(object sender, System.EventArgs e) { this.ParentForm.Text=this.t1.Text; } private void t2_TextChanged(object sender, System.EventArgs e) { this.Text=this.t2.Text; } private void t3_TextChanged(object sender, System.EventArgs e) { this.ParentForm.MdiChildren[0].Text=this.t3.Text; } }} 1.Form1 newMDIChild= new Form1 () ; newMDIChild.MdiParent = this; newMDIChild.Show();2.Form2 frm2= new Form2();frm2.Show(); using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;namespace test{ /// <summary> /// Form1 的摘要说明。 /// </summary> public class Form1 : System.Windows.Forms.Form { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(292, 273); this.IsMdiContainer = true; this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); } #endregion /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_Load(object sender, System.EventArgs e) { Form2 f2=new Form2(); Form3 f3=new Form3(); f2.MdiParent=f3.MdiParent=this; f2.Show(); f3.Show(); } }} using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;namespace test{ /// <summary> /// Form3 的摘要说明。 /// </summary> public class Form3 : System.Windows.Forms.Form { /// <summary> /// 必需的设计器变量。 /// </summary> private System.ComponentModel.Container components = null; public Form3() { // // Windows 窗体设计器支持所必需的 // InitializeComponent(); // // TODO: 在 InitializeComponent 调用后添加任何构造函数代码 // } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { // // Form3 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(292, 273); this.Name = "Form3"; this.Text = "Form3"; this.Load += new System.EventHandler(this.Form3_Load); } #endregion private void Form3_Load(object sender, System.EventArgs e) { } }} Socket-客户端高频率发送消息的问题 疯了,再次求助~~ 那位弟兄帮我看一下,这个SQL过程怎么没有输出结果呢,分不够可以加 listview控件,在拖动列时,不改变listview总宽度,自动重新分配各列宽度 treeView显示问题 PrintDocument ,为什么预览时看到有数据,打印出来却是空白 在网页中显示指定文件夹中的内容??? 请问:如何在DataGrid中双击选中一行,而不是选中一个Cell (求教)C#代码实现网页视频全屏 一个小问题 rtf文件如何加密? 求救!!!,如何对int数据类型进行位操作???
newMDIChild.MdiParent = this;
newMDIChild.Show();
2. Form2 frm2=new Form2();
frm.Show();可以给分了吧
在Form1上用((Form2)this.MdiChildren).Width这是从父窗体调用子窗体
在Form2上用((Form1)this.MdiParent).Width这是从子窗体调用父窗体
如果是多个窗体的话就用foreach循环找一下类型
子窗体和子窗体之间的调用也和上面的差不多。
newMDIChild.MdiParent = this;
newMDIChild.Show();
2.Form2 frm2= new Form2();
frm2.Show();
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;namespace test
{
/// <summary>
/// Form2 的摘要说明。
/// </summary>
public class Form2 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox t1;
private System.Windows.Forms.TextBox t2;
private System.Windows.Forms.TextBox t3;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form2()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.t1 = new System.Windows.Forms.TextBox();
this.t2 = new System.Windows.Forms.TextBox();
this.t3 = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(24, 40);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(66, 14);
this.label1.TabIndex = 0;
this.label1.Text = "Form1.Text";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(24, 80);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(66, 14);
this.label2.TabIndex = 1;
this.label2.Text = "Form2.Text";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(24, 120);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(66, 14);
this.label3.TabIndex = 2;
this.label3.Text = "Form3.Text";
//
// t1
//
this.t1.Location = new System.Drawing.Point(96, 40);
this.t1.Name = "t1";
this.t1.TabIndex = 3;
this.t1.Text = "textBox1";
this.t1.TextChanged += new System.EventHandler(this.t1_TextChanged);
//
// t2
//
this.t2.Location = new System.Drawing.Point(96, 80);
this.t2.Name = "t2";
this.t2.TabIndex = 4;
this.t2.Text = "textBox2";
this.t2.TextChanged += new System.EventHandler(this.t2_TextChanged);
//
// t3
//
this.t3.Location = new System.Drawing.Point(96, 120);
this.t3.Name = "t3";
this.t3.TabIndex = 5;
this.t3.Text = "textBox3";
this.t3.TextChanged += new System.EventHandler(this.t3_TextChanged);
//
// Form2
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.t3,
this.t2,
this.t1,
this.label3,
this.label2,
this.label1});
this.Name = "Form2";
this.Text = "Form2";
this.Load += new System.EventHandler(this.Form2_Load);
this.ResumeLayout(false); }
#endregion private void Form2_Load(object sender, System.EventArgs e)
{
this.t1.Text=this.ParentForm.Text;
this.t2.Text=this.Text;
this.t3.Text=this.ParentForm.MdiChildren[0].Text;
} private void t1_TextChanged(object sender, System.EventArgs e)
{
this.ParentForm.Text=this.t1.Text;
} private void t2_TextChanged(object sender, System.EventArgs e)
{
this.Text=this.t2.Text;
} private void t3_TextChanged(object sender, System.EventArgs e)
{
this.ParentForm.MdiChildren[0].Text=this.t3.Text;
}
}
}
newMDIChild.MdiParent = this;
newMDIChild.Show();
2.Form2 frm2= new Form2();
frm2.Show();
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;namespace test
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.IsMdiContainer = true;
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load); }
#endregion /// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
} private void Form1_Load(object sender, System.EventArgs e)
{
Form2 f2=new Form2();
Form3 f3=new Form3(); f2.MdiParent=f3.MdiParent=this; f2.Show();
f3.Show();
}
}
}
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;namespace test
{
/// <summary>
/// Form3 的摘要说明。
/// </summary>
public class Form3 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null; public Form3()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows Form Designer generated code
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
//
// Form3
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form3";
this.Text = "Form3";
this.Load += new System.EventHandler(this.Form3_Load); }
#endregion private void Form3_Load(object sender, System.EventArgs e)
{
}
}
}