关于动态创建控件,第二次赋值不能显示解决办法

来源:互联网 发布:mac怎么阻止弹出网页 编辑:程序博客网 时间:2024/05/23 01:15

动态创建控件并显示在窗体上的panel上

 

 

第一次能正常赋值并显示所赋值

第二次却不能正常赋值并显示所赋值

解决办法:

foreach (Control cl in this.panel_Button.Controls)
                {
                    if (cl.GetType() == typeof(System.Windows.Forms.TextBox))
                    {
                        if (cl.Name == "txtBox08")//根据控件名称查找并赋值
                        {
                            cl.Text =frm.SelectDpID ;
                        }
                    }
                }