C#语言 在winform窗体中 有一个button 有一个text.box显示框 要求 如下

C#语言 在winform窗体中 有一个button按钮 有一个text.box显示框 要求 单击button显示该text.box 框中的内容 当再次点击button按钮时 text.box 框 变为隐藏
最好给点代码

bool flag = true;
private void btnOK_Click(object sender, EventArgs e)
{
if (flag)
{
this.txtName.Text = "张三";
flag = false;
}
else
{
if (txtName.Visible)
{
this.txtName.Visible = false;
}
else
{
this.txtName.Visible = true;
}
}
}
单击时显示文本框的内容,再次点击button按钮时 text.box 框 变为隐藏。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-07-26
在button的onclick里面写:
textBox1.Visible=!textBox1.Visible;
就可以了
第2个回答  2012-07-26
if (textBox1.Visible == true)
{
textBox1.Visible = false;
}
else
{
textBox1.Visible = true;
}
相似回答