Tech Off Thread

2 posts

Loading embedded image in winforms control.

Back to Forum: Tech Off
  • User profile image

    I am writing a control that inherits from the panel control. I want to load an embedded image as the background image for my panel control. However every measure i have taken to load my embedded image has resulted in an error when adding the control to an application. Any ideas on what i can do to fix it?

  • User profile image

    How about some source code of what you've tried? What exactly do you mean by an "embedded image?"

    Embedded as a resource in the project? If so, are you sure you've got the resource name correct when you load it? I use the following code to find the names of resources embedded in an assembly:

    Assembly a = Assembly.GetExecutingAssembly();
    string [] resNames = a.GetManifestResourceNames();

    The resNames array will have all of the resources in it. The name may surprise you, as it will have the full namespace name, such as "StarTechnologies.SdtGui.VisioSupport.ImageList16.png" where the namespace name (in this case, "StarTechnologies.SdtGui.VisioSupport") is, I believe, the Default Namespace property of the assembly's project.

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.