Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My question is that i have an hashtable in my program , simply i want to display all key,value pair of this hashTable into Datagrid view in my c# form application...
kINDLY answer my question i tried that code but nothing happens...

C#
 dataGridView1.DataSource = hashtable.Cast<DictionaryEntry>().Select(x => new { Col1 = x.Key.ToString(), Col2 = x.Value.ToString() }).ToList();}</pre>

I have posted that same question to forums but still no one has helped me...

I am surprised that why these programmers are not able of answering this question...
Posted
Updated 1-Mar-14 19:26pm
v3
Comments
Krunal Rohit 2-Mar-14 3:20am    
what is the type of the Value on dictionary ?

-KR

1 solution

I just cannot understand how it can be a problem. There can be different way to achieve that. In simplest case, you create two string columns (not counting row headers), one representing keys, another one — values. In the loop by all key-value pairs, fill in both columns. It will take few lines of code. As I don't know if you want to edit data, you need to make at least the key column read-only, because editing a key would be invalid operation. Depending on the type of the values, you might be able to edit them.

—SA
 
Share this answer
 

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