2011-01-31 68 views
1

例如,我使用一个循环来创建具有特定参数的“鸟”对象列表。 但我也需要每个鸟物体在winform上有一个pictureBox,任何想法,我该怎么做,即动态创建并稍后删除一个pictureBox?C#,动态创建图片框?

谢谢!

回答

1

伪代码:

list<picturebox> 

Instantiate the one needed 

Initialize every picturebox that are needed 

Add them to the form (form.control.add) 

If needed remove them from the form, (form.control.remove) 
+0

这是伪,PictureBox,列表,Controls.Add,Controls.Remove。如果没有首先实例化它,你无法初始化PictureBox。 :/ – 2011-01-31 16:11:24

+0

@基伦·约翰斯通,我会假设他/他会知道:-)但我仍然会加上它 – Fredou 2011-01-31 16:13:06

1

您可以创建一个新的PictureBox实例,设置其属性,并将其添加到表单或面板的Controls集合中。