Windows窗体未正确打开 [英] Windows Form Not opening Properly
本文介绍了Windows窗体未正确打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的问题是,当我通过点击form1打开一个表单,然后form2未正确打开意味着它的所有控件,按钮等都没有出现。所以请建议我能为此做些什么。
谢谢。
编辑:
Hi,
My problem is that when i am opening a form via clicking on form1, then form2 is not opens properly means all of its controls, buttons etc. are not appearing on it. so please suggest me what can i do for this.
Thank You.
Form1:
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
public void button1_Click(object sender, EventArgs e)
{
if (checkBox1.Checked || checkBox2.Checked)
{
label2.Visible = true;
label3.Visible = true;
label3.Text = "Will Be Your Life Partener";
if (checkBox1.Checked)
{
label2.Text = " Mrs." + textBox1.Text + " " + textBox2.Text;
}
else
label2.Text = "Mr." + textBox2.Text;
}
else
{
label2.Visible = true;
label2.Text = "Please Select Your Prefix";
}
}
public void button2_Click(object sender, EventArgs e)
{
label2.Visible = true;
label3.Visible = false;
label2.Text = "Thank You " + textBox1.Text;
LF form2 = new LF(this);
form2.ShowDialog();
}
private void label3_Click(object sender, EventArgs e)
{
}
public string PublicProperty { get; set; }
}
}
Form2:
public partial class LF : Form
{
public LF(Form1 parent)
{ this.parentForm = parent; }
public LF()
{
InitializeComponent();
}
public void Form2_Load(object sender, EventArgs e)
{
}
public void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.Equals("vijay"))
{
label1.Text = "Mrs. Pareek";
}
}
public void button2_Click(object sender, EventArgs e)
{
label1.Text = "Thank You" + textBox1.Text;
}
public Form1 parentForm { get; set; }
}
推荐答案
你的问题在于
You problem is in
public LF(Form1 parent) { this.parentForm = parent; }
你需要调用InitializeComponent;
You need to call InitializeComponent;
public LF(Form1 parent)
{
this.parentForm = parent;
InitializeComponent();
}
这篇关于Windows窗体未正确打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文