I want to make a C# DataGridView’s DataSource be a HashTable where there are two columns:
- The first one would be the key;
- The second the value.
Is this possible?
EDIT: Please see my comment about setting/getting the value from/to a hashtable.
Thanks!
The problem here is that you cannot bind directly to a
HashTable. You’ll need something that implements:IList,IListSource,IBindingList,IBindingListView. HashTable does not implement any of those interfaces.Try using LINQ to get your
HashTableinto aList:Note that the anonymous class has 2 named properties (I used
Col1andCol2for brevity. Your grid must know about them exactly: