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

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

2024-05-04 02:31:34

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 框 变为隐藏。
浅沫记忆

2024-05-04 05:04:20

在button的onclick里面写:
textBox1.Visible=!textBox1.Visible;
就可以了
臣妾做不到

2024-05-04 04:51:32

if (textBox1.Visible == true)
{
textBox1.Visible = false;
}
else
{
textBox1.Visible = true;
}