0

Is there a way to set the image from one PictureBox object to another? For example:

pictureboxA1.image = pictureboxB1.image
pictureboxA2.image = pictureboxB2.image
pictureboxA3.image = pictureboxB3.image

I did a similar thing with TextBox controls, but this code isn't working for me:

For i = 0 To 2
  Me.Controls("picturebox" + "A" & i + 1).image = Me.Controls("picturebox" + "B" & i + 1).image
Next i

When I run this, I get an error stating .image is not a member of 'System.Windows.Forms.Control'.


i know that is pictureboxA1.image = pictureboxB1.image.

but if i try like this

For i = 0 To 2
  Me.Controls("picturebox" + "A" & i + 1).image = Me.Controls("picturebox" + "B" & i + 1).image
Next i

it says that image is not a member of controls. because i have to do this pictureboxA1.image = pictureboxB1.image, 21 times.

like pictureboxA1, pictureboxA2, ... 3, 4, 5, 6, 7 until 21.

and if i do it like this

pictureboxA1.image = pictureboxB1.image

i have to right the code 21 times and if i do it with for its just one time xD.

and i tryed .picture it says the same thing

4

1 回答 1

1

Sorry, I should have seen this sooner. You need to set the control to a PictureBox in order for it to recognize the property. I think. Something like this might work. I don't have access to a PictureBox control, so it's a guess:

Dim pic as PictureBox

For i = 0 To 2
  set pic = Me.Controls("picturebox" + "A" & i + 1)
  pic.image = Me.Controls("picturebox" + "B" & i + 1).image
Next i
于 2012-11-11T23:17:51.570 回答