Stream imgStream = null;
Bitmap bmp = null;
// get a reference to the current assembly
Assembly a = Assembly.GetExecutingAssembly();
// get a list of resource names from the manifest
string [] resNames = a.GetManifestResourceNames();
foreach(string s in resNames)
{
if(s.EndsWith(".bmp"))
{
// attach to stream to the resource in the manifest
imgStream = a.GetManifestResourceStream(s);
if( !(null==imgStream) )
{
// create a new bitmap from this stream and
// add it to the arraylist
bmp = Bitmap.FromStream( imgStream ) as Bitmap;
if( !(null==bmp) )
{
pics.Add( bmp );
}
bmp = null;
imgStream.Close();
imgStream = null;
}
}
}
if(comboBox1.Text == "Apple")
{
Bitmap bgimage = pics[0] as Bitmap;
this.BackgroundImage = bgimage;
}