using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Form Form2 = new Form();
Form2.Show();
}
}
}
为何我运行时Form2里面有控件,却无法显示
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Form Form2 = new Form();
Form2.Show();
}
}
}
为何我运行时Form2里面有控件,却无法显示
=>
Form2 F2 = new Form2();
F2.Show();因为你的代码实例化的不是Form2而是Form。Form是基类,空白窗体。
Form2.Show();汗。
Form2 f2=new Form2();
f2.Show();