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 469719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:48:45+00:00 2026-05-12T23:48:45+00:00

There is a Form with a ToolStrip. This ToolStrip contains a ToolStripButton. I want

  • 0

There is a Form with a ToolStrip. This ToolStrip contains a ToolStripButton. I want to assign an image to this button:

this.btnSaveFile.Image = Bitmap.FromFile("C:\\Work\\Icons\\png\\save.png");

It works only if there is save.png on specified path. Otherwise, I get an FileNotFound Exception.

If I created a Form via Form Designer, Visual Studio would create a code like this:

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

toolStripButton9.Image here is not a real name. Visual Studio takse my file save.png and transform it into toolStripButton9.Image.

But I create a form programmatically, without Designer. And my question is how to assign an image to the ToolStripBotton programmatically?

I tried to add the image to the project, but it didn’t help much. I have no idea how to make Visual Studio grab it and embed into my executable so that I wouldn’t need this file on specified location.

In MSDN, I only see the solution like that:

this.toolStripButton1.Image = Bitmap.FromFile("c:\\NewItem.bmp");

But it doesnt’ work as I told above. I understand there is a simple solution but don’t see it. Could you please give me a hint?

  • 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-05-12T23:48:46+00:00Added an answer on May 12, 2026 at 11:48 pm

    In Visual Studio, Open your “Properties” folder in the solution explorer, then open the Resources.resx file and add a existing image file as resource. You can then use it programmatically via the Resource static class:

    Image x = Resources.MyResourceImage;
    

    A full example of the code I suggest:

    using System.Windows.Forms;
    using Testapplication.Properties;
    
    namespace Testapplication {
        public class Class1 {
            public Class1() {
                Form MyForm = new Form();
                ToolStrip MyToolStrip = new ToolStrip();
                MyForm.Controls.Add(MyToolStrip);
    
                ToolStripButton MyButton = new ToolStripButton();
                MyToolStrip.Items.Add(MyButton);
    
                MyButton.Image = Resources.MyResourceImage;
    
                MyForm.Show();
            }
        }
    }
    

    Don’t forget to add a using to YourApps’ Properties namespace. Your Resources.resx (.cs) file resides in that namespace and is used to provide strong-types object references like images. In your case, replace “MyResourceImage” with “save” (omit the quotes).

    ps. A glance at the most important part of my Resources.designer.cs file:

    internal static System.Drawing.Bitmap MyResourceImage {
        get {
            object obj = ResourceManager.GetObject("MyResourceImage", resourceCulture);
            return ((System.Drawing.Bitmap)(obj));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a good way to create a form in VB6 that can easily
Is there a way to use form fields that does not correspond to database
Is there any way for the main form to be able to intercept events
Is there an easy way to have the form helpers set the tabindex parameter
Is there any GUI toolkit for Python with form designer similar to Delphi, eg
Is there a .NET Control Similar to the Access 2007 Split Form? Or has
There are some HTML based games (ie bootleggers.us) that have a simple login form
Is there any way to tile all of the form children of an mdi
Is there a standard way to convert an XSD to an input form (ASP.NET
Is there a way to set the StartPosition of a Windows Forms form using

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.