如何在Windows窗体中检测控件并进行编辑c#

问题描述 投票:-1回答:1

enter image description here我的表格

所以,我有一个带有TableLayoutPanel的Form,其中包含文本框。我需要代码来检查表单上是否有文本框,并且该文本框为空-然后在其中编写文本否则{继续寻找现有的空文本框}顺序无关紧要

c# winforms testing controls read-write
1个回答
0
投票
foreach (Control contr in tableLayoutPanel1.Controls)
        {
            if (contr is RichTextBox)
            {
                if ((contr as RichTextBox).Text == string.Empty)
                {
                    contr.Text = str_product;
                }
            }

        }
© www.soinside.com 2019 - 2024. All rights reserved.