,大一的C#。要求编写一个WINDOWS窗体应用程序,窗体上有一个文本框和两个按钮(显示和清屏)
单击显示按钮时。文本框的背景变为蓝色并且居中显示努力学习C#。单击清除按钮,文本框的背景变回白色并清除文本框的内容。希望大家帮帮忙,好的我送30分。...
单击显示按钮时。文本框的背景变为蓝色并且居中显示 努力学习C#。单击清除按钮,文本框的背景变回白色并清除文本框的内容。 希望大家帮帮忙,好的我送30分。
展开
展开全部
在VS中新建一个Windows 窗体应用程序项目,然后从工具箱中拖拽两个按钮和一个文本框到Form1窗体中,分别双击两个按钮之后(其实就是建立按钮点击事件),在代码中粘贴如下代码即可.
private void button1_Click(object sender, EventArgs e)
{
this.textBox1.BackColor = Color.Blue;
this.textBox1.TextAlign = HorizontalAlignment.Center;
this.textBox1.Text = "努力学习C#!";
}
private void button2_Click(object sender, EventArgs e)
{
this.textBox1.BackColor = Color.White;
this.textBox1.TextAlign = HorizontalAlignment.Left;
this.textBox1.ResetText();
}
private void button1_Click(object sender, EventArgs e)
{
this.textBox1.BackColor = Color.Blue;
this.textBox1.TextAlign = HorizontalAlignment.Center;
this.textBox1.Text = "努力学习C#!";
}
private void button2_Click(object sender, EventArgs e)
{
this.textBox1.BackColor = Color.White;
this.textBox1.TextAlign = HorizontalAlignment.Left;
this.textBox1.ResetText();
}
展开全部
往窗体中添加一个 label 两个Button 控件
添加两个按钮的单击事件,如下:
private void button1_Click(object sender, EventArgs e)
{
label1.Visible = true;
label1.Text = "努力学习C#";
label1.BackColor = Color.Blue;//背景颜色为蓝色
label1.Location = new Point(50, 50);//位置
}
private void button2_Click(object sender, EventArgs e)
{
label1.Text = "";
label1.Visible = false;//隐藏
label1.BackColor = Color.White;
}
添加两个按钮的单击事件,如下:
private void button1_Click(object sender, EventArgs e)
{
label1.Visible = true;
label1.Text = "努力学习C#";
label1.BackColor = Color.Blue;//背景颜色为蓝色
label1.Location = new Point(50, 50);//位置
}
private void button2_Click(object sender, EventArgs e)
{
label1.Text = "";
label1.Visible = false;//隐藏
label1.BackColor = Color.White;
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private void button1_Click(object sender, EventArgs e)
{
this.textBox1.BackColor = Color.Blue;
this.textBox1.TextAlign = HorizontalAlignment.Center;
this.textBox1.Text = "努力学习C#!";
}
private void button2_Click(object sender, EventArgs e)
{
this.textBox1.BackColor = Color.White;
this.textBox1.TextAlign = HorizontalAlignment.Left;
this.textBox1.ResetText();
}
{
this.textBox1.BackColor = Color.Blue;
this.textBox1.TextAlign = HorizontalAlignment.Center;
this.textBox1.Text = "努力学习C#!";
}
private void button2_Click(object sender, EventArgs e)
{
this.textBox1.BackColor = Color.White;
this.textBox1.TextAlign = HorizontalAlignment.Left;
this.textBox1.ResetText();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询