如何清除C#中TextBox中的所有数据/字符串 [英] How to clear all data / string in a TextBox in C#
本文介绍了如何清除C#中TextBox中的所有数据/字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在谷歌上快速浏览了一下,没有找到任何简单的东西.
I have had a quick look on Google and didn't pull anything simple up.
我试过了:
textBox5.Clear();
textBox5.Text=("");
textBox5.Text="".ToString();
推荐答案
你可以试试:
foreach ( Control ctl in Parent.Controls) {
if (ctl.GetTyep()== TextBox)
ctl.text = "";
}
还有你为什么要这样做
textbox.Text = (""); //You don't need the parenthesis here
textbox.Text = "".toString(); //the .toString() is definitly not needed.
如果你只想要一个文本框,那么:
If you only want it for a single textbox then:
myTextBox.Text = String.Empty;
或
myTextBox.Text = "";
这篇关于如何清除C#中TextBox中的所有数据/字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文