Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I've a Window form application, it's a multi-language program, and I create a file of
MyRes.en-US including all string of object in program for user with English language.

The MyRes.en-US has tree items of 'Name', 'Value' and 'Comment', I can implement following 2 lines to access the string in 'Value' :

C#
ResourceManager rm = new ResourceManager(filepath.MyRes, typeof(MainForm).Assembly);
Label_A.Text = rm.GetString(ItemName_String, Culture);


It works well, but, my question now is as follows :
How can I get each string of item of 'Name', 'Value' and 'Description' in each row of MyRes.en-US ?

Thanks of your kind response
Posted
Updated 2-May-13 2:20am
v2

1 solution

Looking for this ?
C#
ResourceSet resourceSet = MyResourceClass.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
foreach (DictionaryEntry entry in resourceSet)
{
    string resourceKey = entry.Key;
    object resource = entry.Value;
}
 
Share this answer
 
Comments
Sports Kuo 2-May-13 23:45pm    
Thanks CrystalB,

I write lines according to your suggestion as below :

ResourceSet resourceSet = rm.GetResourceSet(culture, true, true);
string resourceKey;
string resourceValue;
foreach (DictionaryEntry entry in resourceSet)
{
resourceKey = (string)entry.Key;
resourceValue = (string)entry.Value;
}

and it wors well, however, it can only get the string for 'Name' and 'Value', how can I get the string of 'Description' in rm ?

Thanks again of your fully support.
CrystalB 3-May-13 9:08am    
OK try this link
http://msdn.microsoft.com/en-us/library/system.resources.resxdatanode.aspx
Sports Kuo 6-May-13 1:31am    
Thanks CrytalsB, it works well.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900