c#运行子窗体时异常
画了一个界面,Form1是登录窗体,Form2是父窗体,剩下的是子窗体。调试Form2的时候就出现下图的错误。这种的情况是怎么回事?该如何解决。publicstaticc...
画了一个界面,Form1是登录窗体,Form2是父窗体,剩下的是子窗体。调试Form2的时候就出现下图的错误。这种的情况是怎么回事?该如何解决。
public static class Program {//这个是Program.cs代码
public static Form1 f1 = null; public static Form2 f2 = null; [STAThread]
public static void Main() { Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
f1 = new Form1(); f2 = new Form2(); Application.Run(f1); }
下面的是主窗体代码,通过安登录按钮打开From2父窗体
public partial class Form1 : Form { public Form1() {
InitializeComponent(); } private void button1_Click(object sender, EventArgs e) {
Program.f2.Visible = true; Program.f1.Visible = false; }
private void button2_Click(object sender, EventArgs e) { Application.Exit(); }
private void Form1_Load(object sender, EventArgs e) { }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
e.Cancel = true; this.Visible = false; } } 提示文字过长,只能这么粘了 展开
public static class Program {//这个是Program.cs代码
public static Form1 f1 = null; public static Form2 f2 = null; [STAThread]
public static void Main() { Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
f1 = new Form1(); f2 = new Form2(); Application.Run(f1); }
下面的是主窗体代码,通过安登录按钮打开From2父窗体
public partial class Form1 : Form { public Form1() {
InitializeComponent(); } private void button1_Click(object sender, EventArgs e) {
Program.f2.Visible = true; Program.f1.Visible = false; }
private void button2_Click(object sender, EventArgs e) { Application.Exit(); }
private void Form1_Load(object sender, EventArgs e) { }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) {
e.Cancel = true; this.Visible = false; } } 提示文字过长,只能这么粘了 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询