Retrieving resource image files that are embedded in a custom control

  • Thread starter Thread starter Joanne
  • Start date Start date
J

Joanne

Hi,

I have a custom control that has a folder (resources) of embedded bmp
images. I use the public method (ImageName) below to tell the control the
string name of the embedded image that I want the control to display. The
method should assign a new bitmap image from the custom controls embedded
image to my private Image field using the GetManifestResourceStream method.

I'm setting imageName to namespace.resourcesfolder.filename.bmp like
"NS_TitleBar.resources.trainingpic1.bmp" but I keep getting an error from
the *forms designer* that says the image cannot be set to null. so it looks
like the main line of code below cannot find the embedded resource image.

Any ideas?

public string ImageName
{
get
{
return this.imageName;
}
set
{
this.imageName = value;
this.image = new
System.Drawing.Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream(imageName));
this.Invalidate();
}
}
 
Are you sure you are not getting from designer error *before* the code below
had a chance to execute?
 
Back
Top