WinForm上一个bottom1,点击就在窗体上生成一个textbox1控件和一个bottom2控件怎么做?
再在textbox1中输入文字点击bottom2句把输入的文字设置为窗体的标题。注:不能使用Visible属性...
再在textbox1中输入文字点击bottom2句把输入的文字设置为窗体的标题。注:不能使用Visible属性
展开
2个回答
展开全部
C#
public partial class Form1 : Form {
private Button buttton2; private TextBox textbox1;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (this.buttton2 == null)
{
this.buttton2 = new Button();
this.buttton2.Click += new EventHandler(button2_Click);
}
this.buttton2.Text = "Button2";
this.buttton2.Top = 100;
this.buttton2.Left = 150;
this.Controls.Add(this.buttton2);
if (this.textbox1 == null)
{
this.textbox1 = new TextBox();
}
this.textbox1.Top = 120 + this.buttton2.Height;
this.textbox1.Left = 150;
this.Controls.Add(this.textbox1);
}
void button2_Click(object sender, EventArgs e)
{
this.Text = this.textbox1.Text;
}
}
public partial class Form1 : Form {
private Button buttton2; private TextBox textbox1;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (this.buttton2 == null)
{
this.buttton2 = new Button();
this.buttton2.Click += new EventHandler(button2_Click);
}
this.buttton2.Text = "Button2";
this.buttton2.Top = 100;
this.buttton2.Left = 150;
this.Controls.Add(this.buttton2);
if (this.textbox1 == null)
{
this.textbox1 = new TextBox();
}
this.textbox1.Top = 120 + this.buttton2.Height;
this.textbox1.Left = 150;
this.Controls.Add(this.textbox1);
}
void button2_Click(object sender, EventArgs e)
{
this.Text = this.textbox1.Text;
}
}
追问
再在textbox1中输入文字点击bottom2句把输入的文字设置为窗体的标题。注:不能使用Visible属性
追答
已经修改答案,注意查看
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询