Share via


Resource Editor (RESEDITOR)

The Resource Editor (ResEditor) sample application is also a useful tool. It provides a graphical interface that allows you to construct .resources files containing bitmaps, icons, and strings. The following figure shows using ResEditor to construct a resources file containing both strings and images:

This program consists of two source-code files: ResEditor.cs and ResHolder.cs. ResEditor.cs handles the control of the program, the reading and writing of .resources and .resx files, and the Windows Forms user interface. ResHolder.cs implements a class that holds resources and inherits from ICustomTypeDescriptor, which means that resources can be conveniently loaded into a property window for browsing and editing. The following code shows how to do this:

private void ReadResXFile(string fileName) {
    ResXResourceReader rrdr = null ; 
    try {
        rrdr = new ResXResourceReader(fileName);
        currentResHolder = new ResHolder(rrdr);
        propertyGridResources.SelectedObject = currentResHolder;
    }
    finally {
        if (null != rrdr) rrdr.Close();
    }
}