如何使此代码适用于多个文本框

时间:2015-01-03 11:28:52

标签: c# winforms textbox label

foreach (TextBox c in this.Controls)
{
    foreach (Label lb in this.Controls)
    {   
        if (c.Text == string.Empty)
            c.Visible = false;
        else
        {
            c.Visible = true;
            if (c.Visible == lb.Visible)
                lb.Visible = true;
            else
                lb.Visible = false;
        }
    }
}

0 个答案:

没有答案