Skip to content

PictureBox image check?

GaLaZ

Asked Dec 11, 2008, 4:36 AM EST3 answers
Share
LinkedInX
Hi,

I've got a fast question, is there any possibility to check what kind of file is now loaded to for example my pictureBox1?

and another one, how can I remove image from pictureBox ? so later I can add there another one... Using null won't help :(

thanks

Greg.

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Bechir Bejaoui
    +1
    For the first question

    strnig path = pictureBox1.ImageLocation;

    For the second question

    System.Drawing.Image image = System.Drawing.Image.FromFile(thenewpathhere);
    pictureBox1.Image = image;

    that's it
    +1
  • +1
    thanks, that helped me a lot :)

    but now I have to face another problems with that...

    1. I need to check if (in anyone of my pictureBoxes are the same pictures...)

     if (pictureBox1.image = logo.gif && pictureBox2. image= logo.gif){}

    how could I solve it?

    second...

    2. I've got four picture Boxes with loaded in images. Next I need to remove te pictures, and make sure that those pictureBoxes are ready to load in new images :)

    thanks for help again
    +1
  • Bechir Bejaoui
    +1
    Sure, I give you the most efficient way to do that, there is an object called ImageList that is specially leveraged to hold an image collection
    you do as follow

    ImageList oImgList  = new ImageList();
    oImgList.Items.Add(Image1);
    .
    .
    oImgList.Items.Add(Imagen);

    then you can refer your images by the index, I mean

    if(PictureBox.Iamge = oImgList.Images[index1] ..... patati patata  barwet barwet.....
    ;-{)
    +1