|
-
Jun 28th, 2009, 05:00 PM
#1
Thread Starter
Member
Random pictures loaded in picturebox from my.resources
Hi guys,
I have one little dillema:
I have a picture box and 10 images I want to load randomly. I cannot use imagelist because these images have a width of 400 and imagelist limits the width to 256. I have added these images to my.resources.
The thing is I cannot figure out how can I randomly load each of these pictures to this picturebox
Any help will be greatly appreciated.
Thanks
-
Jun 28th, 2009, 06:22 PM
#2
Re: Random pictures loaded in picturebox from my.resources
try this:
vb Code:
dim images() as bitmap = {my.resources.imagename1,my.resources.imagename2...my.resources.imagename10}
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
picturebox1.image = images(new random().next(0,10))
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 29th, 2009, 02:57 AM
#3
Thread Starter
Member
Re: Random pictures loaded in picturebox from my.resources
Thanks. I was using something similar inside a function and I had some errors. Your solution works. Thanks
-
Jun 29th, 2009, 03:11 AM
#4
Thread Starter
Member
Re: Random pictures loaded in picturebox from my.resources
One more thing though, If I want to add a certain link to each picture, how do I know when a certain picture is loaded into the picturebox?
-
Jun 29th, 2009, 10:19 AM
#5
Re: Random pictures loaded in picturebox from my.resources
use the picturebox tag property to store the image array index
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 29th, 2009, 10:34 AM
#6
Thread Starter
Member
Re: Random pictures loaded in picturebox from my.resources
how can I do this in code?
Thanks
-
Jun 29th, 2009, 10:41 AM
#7
Re: Random pictures loaded in picturebox from my.resources
what sort of link do you want to associate with each image? will it always be the same?
heres how to assign the array index to the picturebox. let me know about the link. we might be able to improve it.
vb Code:
dim images() as bitmap = {my.resources.imagename1,my.resources.imagename2...my.resources.imagename10}
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dim index as integer = new random().next(0,10)
picturebox1.image = images(index)
picturebox1.tag = index
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 29th, 2009, 11:07 AM
#8
Thread Starter
Member
Re: Random pictures loaded in picturebox from my.resources
different hyperlink for each image
-
Jun 29th, 2009, 11:18 AM
#9
Re: Random pictures loaded in picturebox from my.resources
vb Code:
dim images() as bitmap = {my.resources.imagename1,my.resources.imagename2...my.resources.imagename10}
dim links() as string = {"link1","link2",...,"link10"}
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dim index as integer = new random().next(0,10)
picturebox1.image = images(index)
picturebox1.tag = links(index)
End Sub
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
MsgBox(PictureBox1.Tag)
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 29th, 2009, 11:32 AM
#10
Thread Starter
Member
Re: Random pictures loaded in picturebox from my.resources
I want to make the links available on PictureBox1_Click event. Each time I click a image displayed in the picturebox should take me to the corresponding hyperlink for that image.
Any ideas on that?
-
Jun 29th, 2009, 11:36 AM
#11
Re: Random pictures loaded in picturebox from my.resources
vb Code:
Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
if PictureBox1.Tag isnot nothing then process.start(PictureBox1.Tag)
End Sub
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 29th, 2009, 11:58 AM
#12
Thread Starter
Member
Re: Random pictures loaded in picturebox from my.resources
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
|