日期:2014-05-17  浏览次数:20779 次

C#中tablecontrol 检查里边的tabletext为空
界面中有个tablecontrol 里边有两个页面tablepage 现在要求检查tabpage1中的值是否为空 一个一个检查很麻烦 我想用类似这样的检查,不知道该怎么进入判断
foreach (System.Windows.Forms.Control ctr in this.Controls)
                {
                    if (ctr is GroupBox)
                    {
                        foreach (Control ctr1 in ctr.Controls)
                        {
                            if (ctr1.Text.Length <= 0 && ctr1 is TextBox && !ctr1.Name.ToString().EndsWith("Dataname"))
                            {
                                toolStripStatusLabel1.Text = "請輸入" + ctr1.Name.ToString();
                                ctr1.Enabled = true;
                                break;
                            }
                        }
                    }

                }

thank in advance!

------解决方案--------------------
不是跟这个类似么?

foreach (Control control in tabPage1.Controls)
            {
                if (control.Text.Length <= 0 && control is TextBox && !control.Name.ToString().EndsWith("Dataname"))
                {
                    toolStripStatusLabel1.Text = "請輸入" + control.Name.ToString();
                    control.Enabled = true;
                &nbs