开发者

C#, dynamically creating picture boxes?

开发者 https://www.devze.com 2023-02-07 22:28 出处:网络
For example I use a loop to create a list of \"bird\" objects with certain parameters. But I al开发者_如何学编程so need each bird object to have a pictureBox on the winform, any ideas, how do I do tha

For example I use a loop to create a list of "bird" objects with certain parameters. But I al开发者_如何学编程so need each bird object to have a pictureBox on the winform, any ideas, how do I do that, i.e. dynamically create and later delete a pictureBox?

Thanks!


Here's the first result from googling your question title, which has an example of this:

http://www.dreamincode.net/forums/topic/78037-dynamically-create-multiple-picture-boxes/

Another: http://thechaosrift.com/viewtopic.php?f=32&t=4387&p=51006

Did you try something already and have a problem? If not, it's always worth consulting Google to see if you can learn on your own first.


You can create a new PictureBox instance, set its properties, and add it to the Controls collection of a form or panel.


pseudo code:

 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

精彩评论

暂无评论...
验证码 换一张
取 消