清空控件的TeXt属性

 foreach (Control item in groupBox1.Controls)

                    {

                        if (item is TextBox) //判断控件是不是TextBox

                        {

                            item.Text = ""; //如果text就为空

                        }

                        else if (item is ComboBox) //判断控件是不是Combox

                        {

                            ((ComboBox)item).SelectedIndex = -1;

//Item强制转换(Combox

                        }

                      

                    }

 

posted @ 2018-03-28 15:16  WhiteSpace  阅读(421)  评论(0编辑  收藏  举报