Answer the question
In order to leave comments, you need to log in
How to work with the user control resource file?
At the moment I am developing under winforms, writing custom controls. There was a question where to store pictures which this control uses. I decided that I would store them in the resource file (.resx) not of the entire application, but only of my control.
The question is, how do you pull pictures from the control/form resources? If you store pictures in a project resource file, then there are no questions:
System.Drawing.Image myImg = Properties.Resources.ImageName;
or
System.Drawing.Image myImg = global::ProjectName.Properties.Resources.ImageName;
using System.ComponentModel;
//init
ComponentResourceManager resources = new ComponentResourceManager(typeof(MyControlName));
//get image
System.Drawing.Image myImg = resources.GetObject("MyImageName");
private readonly static string myImgName = "myImg_16x16";
System.Drawing.Image myImg = resources.GetObject(myImgName);
Answer the question
In order to leave comments, you need to log in
If I understand the problem correctly, this is easily solved. Open the resource file, the one with the default culture, and set access modifier = internal. This is the drop-down list at the top:
Most likely, you currently have No code generation.
Resources should be accessed like this:
The resource file name is the same as the class name. Those. I have Strings.resx and Strings.ru.resx.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question