如何获取在运行时创建的控件的文本?
private void button1_Click(object sender, EventArgs e)
{
Button btn = new Button();
btn.Top = 50;
btn.Left = 50;
btn.Name = "mybtn";
btn.Text = "My button";
this.Controls.Add(btn);
}
private void button2_Click(object sender, EventArgs e)
{
Console.WriteLine(mybtn.text); // error
}