What is the best way to clear all controls on a form C#?

前端 未结 8 2201
情书的邮戳
情书的邮戳 2020-11-27 18:00

I do remember seeing someone ask something along these lines a while ago but I did a search and couldn\'t find anything.

I\'m trying to come up with the cleanest wa

8条回答
  •  隐瞒了意图╮
    2020-11-27 18:05

    You can loop for control

    foreach (Control ctrl in this)
    {
        if(ctrl is TextBox)
            (ctrl as TextBox).Clear();
    }
    

提交回复
热议问题