private void createimg()
{
this.pix1[renwuadd]=new PictureBox();
this.pix1[renwuadd].Location = new System.Drawing.Point(renwux,renwuy);
this.pix1[renwuadd].Name =renwuname;
this.pix1[renwuadd].Size = new System.Drawing.Size(176, 144);
this.pix1[renwuadd].Image=Image.FromFile(@"image\"+renwusuiji+".gif");
this.Controls.Add(pix1[renwuadd]);
}
我想动态的创建一个PictureBox在界面上。这个createimg()方法用来创建,而我又必须要在一个线程上执行这个方法。错误信息: 在某个线程上创建的控件不能成为在另一个线程上创建的控件的父级。各位大虾,应该怎么才可以解决得到这个问题啊??????
谢谢。
{
this.pix1[renwuadd]=new PictureBox();
this.pix1[renwuadd].Location = new System.Drawing.Point(renwux,renwuy);
this.pix1[renwuadd].Name =renwuname;
this.pix1[renwuadd].Size = new System.Drawing.Size(176, 144);
this.pix1[renwuadd].Image=Image.FromFile(@"image\"+renwusuiji+".gif");
this.Controls.Add(pix1[renwuadd]);
}
我想动态的创建一个PictureBox在界面上。这个createimg()方法用来创建,而我又必须要在一个线程上执行这个方法。错误信息: 在某个线程上创建的控件不能成为在另一个线程上创建的控件的父级。各位大虾,应该怎么才可以解决得到这个问题啊??????
谢谢。
{
if (this.InvokeRequired)
{
this.Invoke( new System.Threading.ThreadStart(this.CreateImgSync), null );
}
else
{
this.createimgsync();
}
}private void createimgsync()
{
this.pix1[renwuadd]=new PictureBox();
this.pix1[renwuadd].Location = new System.Drawing.Point(renwux,renwuy);
this.pix1[renwuadd].Name =renwuname;
this.pix1[renwuadd].Size = new System.Drawing.Size(176, 144);
this.pix1[renwuadd].Image=Image.FromFile(@"image\"+renwusuiji+".gif");
this.Controls.Add(pix1[renwuadd]);
}
http://community.csdn.net/Expert/topic/4455/4455126.xml
pix1[renwuadd].Top=55;
用Invoke的确可以了,但是我创建后,却无法在移动这个控件了。
通过多线程为基于 .NET 的应用程序实现响应迅速的用户
http://www.microsoft.com/china/MSDN/library/enterprisedevelopment/softwaredev/misMultithreading.mspx