问题描述:
我在backgroundworker控件进程中,动态添加了一些用户控件到主窗体的panel容器中,提示
“在某个线程上创建的控件不能成为在另一个线程上创建的控件的父级”相关代码:foreach (DataRow dr in dt.Rows)
{
//动态添加控件
ListControl lc = new ListControl();
lc.Location = new Point(0, 0 + n * 90);
lc.mtb01 = ToTxtValue(dr[1].ToString());
lc.mtb02 = ToTxtValue(dr[2].ToString());
lc.addtime = dr[16].ToString();
pl_list.Controls.Add(lc); 到这一行就提示错误“在某个线程上创建的控件不能成为在另一个线程上创建的控件的父级”
n++;
}
我在backgroundworker控件进程中,动态添加了一些用户控件到主窗体的panel容器中,提示
“在某个线程上创建的控件不能成为在另一个线程上创建的控件的父级”相关代码:foreach (DataRow dr in dt.Rows)
{
//动态添加控件
ListControl lc = new ListControl();
lc.Location = new Point(0, 0 + n * 90);
lc.mtb01 = ToTxtValue(dr[1].ToString());
lc.mtb02 = ToTxtValue(dr[2].ToString());
lc.addtime = dr[16].ToString();
pl_list.Controls.Add(lc); 到这一行就提示错误“在某个线程上创建的控件不能成为在另一个线程上创建的控件的父级”
n++;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货