Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8446891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:02:40+00:00 2026-06-10T10:02:40+00:00

I have a C# form that I am creating completely manually (i.e. without using

  • 0

I have a C# form that I am creating completely manually (i.e. without using the Visual Studio Design View). In this form I have a Label created (simply) as follows:

private Label myLabel = new Label();

Later on in the code, during a callback, I want to set an image for this label. I have found one way to do it and here is the code:

myLabel.Image = Image.FromFile("Images\\mark.png");

This works but the problem is, when I distribute my application I am going to always have to provide a folder (Images) containing mark.png.

This is acceptable I guess but it’s really not what I want…

The interesting thing is, I looked at some other code I created where I used the Visual Studio Design View to add an image to a label and the Designer does it totally different.
It somehow parses the image, figures out the binary, and saves the base64 representation of this binary as a string in the .resx file:

<data name="fileDisconnect.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    <value>
        iVBORw0KGgoAAAANSUhEUgAAABkAAAAXCAYAAAD+4+QTAAAABGdBTUEAAK/INwWK6QAAAAlwSFlzAAAO
        vAAADrwBlbxySQAAAA10RVh0U291cmNlAE51dm9sYaxPNfEAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5F
        ...
        ...
        ns2di2Jn545YY+PJHw3ZbmREJBgZLDwzgehomExoMpmUG1spVLuhAG/80RSKwyEGo7ZBJNKcsrf/Pd7Q
        MOijAUML48mPeAPCJ5FKhMcSBOt9Ach5ThKVujqeQvEa8v8FrglBl5d/7zYAAAAASUVORK5CYII=
</value>

Looking at the Designer file source code you can see it sets the image lable as follows:

this.fileConnect.Image = ((System.Drawing.Image)(resources.GetObject("fileConnect.Image")));

So, as you can see, doing it this way is much more elegant. There is no need to actually save the image to your hard disk and provide the image when delivering your application. The image information is stored in the .resx file and images are set getting the binary content programatically from the .resx.

My question is…. If I am creating my control manually how can I get the same kind of behavior? Can I create a .resx file, open the image with a HEX editor and copy the binary string into the .resx file? Then, when adding the image to the label I could just just do it like above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:02:42+00:00Added an answer on June 10, 2026 at 10:02 am

    If you save the image in Resources, you can just do this:

            Label myLabel = new Label();
            myLabel.Text = "whatever";
            myLabel.Image = Properties.Resources.MyLabelImage;
            this.Controls.Add(myLabel);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a form. As of right now I have simple MAILTO form that
I've creating one ASP web application, in that application one form have to update
I am creating a form designer and have a toolbox that contains images of
I have a form that has label values that I would like to pass
I'm creating a form that has two checkboxes yes and no. I have added
I have an older form that I really don't want to rewrite at this
I currently have form that checks if a user has unsubmitted changes when they
I have a form that I'm submitting through AJAX. The form includes many fields,
I have a form that I want to be validated before showing it initially.
I have a form that sends money value e.g <input type=text name=amount value=N50,000.00 NGN

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.