|
-
May 8th, 2013, 04:29 AM
#6
Thread Starter
New Member
Re: Random Picture Box Generation
 Originally Posted by dday9
What I'd do is not generate random pictureboxes, rather generate random images in a static picturebox. Simply add a picturebox and a button to your form, and then open up the code view. In the code view declare a new list(of images) and a new instance of the random class at the form level. In your form_load event load the desired images to the list using the .Add or the .AddRange method. Next, in the button's click event you'd set the picturebox's image equal to a random item in your list(of images) using the Random.Next:
Code:
PictureBox1.Image = fooList.Item(r.Next(0, fooList.Count + 1))
Thank you! So this is how I can get random images into my picture boxes. I am planning to have multiple, random picture boxes move in from the sides of the form with random images within each of them. So that's sorted.
 Originally Posted by Shaggy Hiker
Yeah, you do. Otherwise, that's what I'd do, too. I don't like creating new controls unless I absolutely have to. Create them once, cache them if needed, then toggle their visibility. Dynamic creation will work, but you may well end up fighting performance issues if you do that.
Yeah, I want to try and avoid any performance issues.
My next step is to randomly assign movement to these picture boxes so that only a select few are in movement.
Cheers for the help guys!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|