Change PictureBox's image to image from my resources?

后端 未结 6 2053
我寻月下人不归
我寻月下人不归 2020-12-08 14:38

How do I set a PictureBox image to an image from my resources?

(I tried this without success: pictuerbox.Image = \"img_location\";)

6条回答
  •  庸人自扰
    2020-12-08 14:48

    You must specify the full path of the resource file as the name of 'image within the resources of your application, see example below.

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PictureBox1.Image = My.Resources.Chrysanthemum
    End Sub
    

    In the path assigned to the Image property after MyResources specify the name of the resource.

    But before you do whatever you have to import in the resource section of your application from an image file exists or it can create your own.

    Bye

提交回复
热议问题