none
Getting a picture from resources. RRS feed

  • Question

  • Hello there,

    Right now im trying to retrieve images from
    Resource, randomly at that within a string

    public static Random rnd = new Random();
    //Spacer
    
    List<string> lst = new List<string>();
                string str = string.Empty;
    lst.Add("firstimage");
    lst.Add("secondimage");
    
     str = lst.OrderBy(xx => rnd.Next()).First();

    which retrieves the text within the list etc,

    But im having a bit of an issue retrieving it within
    the resources heres what ive tried to output to
    a picturebox

    pictureBox1.Image = Properties.Resources.ResourceManager.GetObject(str, Properties.Resources.Culture);

    Any help would be greatly appreciated

    Kind Regards
    Phil.

    Sunday, May 6, 2018 9:15 AM

Answers

  • pictureBox1.Image = (Bitmap)Properties.Resources.ResourceManager.GetObject(str, Properties.Resources.Culture);

    • Proposed as answer by Petr B Sunday, May 6, 2018 10:58 AM
    • Marked as answer by Phil Clinj Sunday, May 6, 2018 10:58 AM
    Sunday, May 6, 2018 9:55 AM

All replies