Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I have built an small Windows Form application, in which I stored some data in resourse file. Now, I want to show those values (key & value) in a datagridview.

How can I accomplish this?
I have tried:
C#
DataTable dt=new DataTable();
            dt.ReadXml(sResxPath);
            dataGridView1.DataSource = dt;
Posted
Updated 15-Feb-22 7:15am
v3
Comments
demouser743 17-Nov-11 7:21am    
Can you show us the sample data that was in resource file

1 solution

This works for me

XML
Dictionary<string, string> resourceMap = new Dictionary<string, string>();
            string filename = "Your resource filepath";
            ResXResourceReader rsxr = new ResXResourceReader(filename);
            foreach (DictionaryEntry d in rsxr)
            {
                resourceMap.Add(d.Key.ToString(), d.Value.ToString());
            }
            dataGridView1.DataSource = resourceMap.ToArray();
 
Share this answer
 
Comments
choudhary.sumit 17-Nov-11 7:45am    
thanx..it works great!
demouser743 17-Nov-11 7:46am    
Welcome buddy :)

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