change Image in pictureBox after event

 

Hi guys...

How does it work do change the image during runtime

e.g.

I instantiated a pictureBox with a local resource like the assistent creates.

this.pictureBox.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox.Image")));

How is it possible to change the image if the user e.g. press a button

this.pictureBox.Image =

 

Thank you for help.

 

Regards..

 



Answer this question

change Image in pictureBox after event

  • hidme

    this.pictureBox.Image = Image.FromFile("filename.jpg");

    or

    this.pictureBox.Load("filename.jpg");

    :-)



  • DanMeyers

    Worked very well.. Thx...

  • limon26

    well it depends really on you and where you want to load the images from. if the user presses a button, you could show an openfiledialog for the user to select an image, then take the filename in the openfiledialog class and replace it with the "filename.jpg" to load the image the user chose :-)

    it is totally up to you where you save the pictures, as long as you get the path and filename correct, thats all that matters. if you only want to load pictures from your application directory, where the app starts, then generally you would do this:

    this.pictureBox.Image = Image.FromFile(Application.StartupPath + "\\" + filenameHere);

    Application.StartupPath gives you the current directory of where the application is running from



  • saddy

    To which resource will the filename relate
    In another words in which folder must the picture saved to use the relative link "filename.jpg"

    Thx..

  • change Image in pictureBox after event