C#子窗体获取父窗体自定义控件里的信息
父窗体上添加自定义控件(两个Text文本框,1个Button),子窗体(2个文本框),先在文本框中输入账号,密码,点击按钮之后,隐藏父窗体,显示子窗体,问子窗体文本框中如何显示在自定义控件中输入的文本框内容????小白求指教
[解决办法]
//父窗体中按钮事件
void btn_Click(object sender, EventArgs e)
{
Form2 f2 = new Form2(this.Controls["txt_Id"].Text.ToString(), this.Controls["txt_Name"].Text.ToString());
f2.MdiParent = this;
f2.Show();
}
//子窗体
private string f2name;
private string f2id;
public Form2(string id,string name)
{
InitializeComponent();
f2name = name;
f2id = id;
}
private void Form2_Load(object sender, EventArgs e)
{
textBox1.Text = f2id;
textBox2.Text = f2name;
}