How to clear the text of all textBoxes in the form?

后端 未结 9 1548
长发绾君心
长发绾君心 2020-11-27 05:15
private void CleanForm()
{
    foreach (var c in this.Controls)
    {
        if (c is TextBox)
        {
            ((TextBox)c).Text = String.Empty;
        }
            


        
9条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 05:46

    Try this:

    var t = this.Controls.OfType().AsEnumerable();
    foreach (TextBox item in t)
    {
        item.Text = "";
    }
    

提交回复
热议问题