[英]How to make textbox appear only after user clicks button in c#
How would I make a textbox appear only after clicking a button. 我如何使文本框仅在单击按钮后出现。 THis means that It should be hidden, and once user clicks, then it can appear. 这意味着它应该被隐藏,并且一旦用户单击,它就会出现。
private void button7_Click(object sender, EventArgs e)
{
// .. what next?
}
You can use Control.Visible
to make any control visible or hidden: 您可以使用Control.Visible
使任何控件可见或隐藏:
private void button7_Click(object sender, EventArgs e)
{
theTextBox.Visible = true;
}
Just set it's Visible
property to false
initially (ie: in the designer). 最初只需将其Visible
属性设置为false
(即:在设计器中)。
Assuming you have defined a TextBox textBox1
somewhere: 假设您在某处定义了TextBox textBox1
:
private void button7_Click(object sender, EventArgs e)
{
textBox1.Visible = !textBox1.Visible;
}
This way you can toggle the visibility. 这样,您可以切换可见性。
You can set it just to true
if you like, but make sure the initial Visible
state, you can set it in the designer, is false
. 您可以根据需要将其设置为true
,但是请确保可以在设计器中将其设置为Visible
的初始状态为false
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.