Search code examples
vb.netimagevisual-studiopicturebox

How to make picture boxes share image?


Okay so, I have three pictureboxes. The first picture box has a binding source which pulls an image from an SQL data base. The two other picture boxes do not have a binding source, and cannot be given the same binding source as they are in different forms.

I need to get the image from picture box one, and have it displayed in the two picture boxes when the user changes form.

Using the following code I have got this to work:

    Private Sub GetPatImage()
       If Me.P_Image.Image IsNot Mainfrm.P_Image.Image Then
           Me.P_Image.Image = Mainfrm.P_Image.Image
       End If
    End Sub

The next issue, is that it takes a couple of seconds for picture box 1 to actually display the image in the first form. So, if the user is quick enough, the image will not be displayed on form change.

Is there a way to make the code run only when the image has been displayed properly in the first form?


Solution

  • What is the first issue?

    For the second one, you can use the LoadCompleted event.