Making text box visible/unvisible c# [closed]

泪湿孤枕 提交于 2019-12-08 12:25:11

问题


I'm working on a windows form application and I have a button and a textbox in it.

When the button is pressed, it should make the textbox visible and hidden.


回答1:


myTextbox.Visible = !myTextbox.Visible;



回答2:


Did you try Google?

textBox1.Visible = false;

You can toggle the visibility by doing:

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



回答3:


WinForm:

private void button1_Click(object sender, System.EventArgs e)
{
    textBox.Visible = !textBox.Visible;
}

WPF:

private void button1_Click(object sender, RoutedEventArgs e)
{
        if (textBox.Visibility != System.Windows.Visibility.Hidden)
            textBox.Visibility = System.Windows.Visibility.Hidden;
        else
            textBox.Visibility = System.Windows.Visibility.Visible;
}



回答4:


You can find an example here

private void button1_Click(object sender, System.EventArgs e)
{
   /* If the CTRL key is pressed when the 
      * control is clicked, hide the control. */ 
   if(Control.ModifierKeys == Keys.Control)
   {
      ((Control)sender).Hide();
   }
}



回答5:


textbox.visible=true;

you should try this on buttonClick event



来源:https://stackoverflow.com/questions/14250082/making-text-box-visible-unvisible-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!