关于winform中窗体跳转的问题... 建议用Form.showDialog()实现模态窗口 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 private void button4_Click(object sender, EventArgs e) { Form2 form2 = new Form2( ); form2.ShowDialog(); //此模式打开,只能对于当前窗体进行操作,而form2.Show()是以非模式打开,即可同时操作多个窗体 form2.Dispose(); } if (ActiveMdiChild is Form1) { return; } else { if (this.ActiveMdiChild != null) { this.ActiveMdiChild.Close(); } Form1 F= new Form1(); F.MdiParent = this; F.Show(); }int Children_Count=this.MdiChildren.Length;for(int i=0;i<Children_Count;i++){if(this.MdiChildren[i].WindowState==FormWindowState.Maximized )this.MdiChildren[i].WindowState=FormWindowState.Normal;} 建议用Form.showDialog()实现模态窗口 program.cs里:namespace justatry{ public class abc { public static int i = 0; //全局变量,判断有没有窗体2 } static class Program { /// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } }}窗体一:namespace justatry{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { if (abc.i == 0) //没有窗体2.则打开 { Form2 form2 = new Form2(); abc.i = 1; //打开后至1 form2.Show(); } } }}窗体二:namespace justatry{ public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { } protected override void OnFormClosing( FormClosingEventArgs e) //对关闭事件做重载 { abc.i = 0; //回0 base.OnFormClosing(e); } }}好了! 支持使用Form.showDialog();顶上! SQL批量插入,数据源来自多表链接 如何实现一个通用的ListView装载显示方法 数据库报表跟水晶报表是一样的吗? 如何编写一个ADSL登陆器 这个效果怎么实现? 想用C#做一个能够透明+鼠标透过的窗口,遇到一些问题 用C#来编写DICOM图象格式转化为BMP格式的源代码或者相关的资料 请问c#的ListBox的“全部选定”怎么做? 如何在存储过程中使用text数据类型~~~~~~~~~~~~~~~~~~~~~~~ 这个网页提取正则表达式怎样写 大家帮忙啊!采用OLEDB的方式连接SQLSERVER,如果选择表的方式为COMMAND,就会报错 网上购物系统 毕业设计
{
Form2 form2 = new Form2( );
form2.ShowDialog(); //此模式打开,只能对于当前窗体进行操作,而form2.Show()是以非模式打开,即可同时操作多个窗体
form2.Dispose();
}
{
return;
}
else
{
if (this.ActiveMdiChild != null)
{
this.ActiveMdiChild.Close();
}
Form1 F= new Form1();
F.MdiParent = this;
F.Show();
}int Children_Count=this.MdiChildren.Length;
for(int i=0;i<Children_Count;i++)
{
if(this.MdiChildren[i].WindowState==FormWindowState.Maximized )
this.MdiChildren[i].WindowState=FormWindowState.Normal;
}
namespace justatry
{
public class abc
{
public static int i = 0; //全局变量,判断有没有窗体2
} static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread] static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}窗体一:
namespace justatry
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (abc.i == 0) //没有窗体2.则打开
{
Form2 form2 = new Form2();
abc.i = 1; //打开后至1
form2.Show();
}
}
}
}窗体二:
namespace justatry
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
} private void Form2_Load(object sender, EventArgs e)
{ } protected override void OnFormClosing( FormClosingEventArgs e) //对关闭事件做重载
{
abc.i = 0; //回0
base.OnFormClosing(e);
}
}
}好了!
顶上!