I’m trying to bind an array of dictionary<string,object> to a datagridview.
The dictionaries will all have the same keys, and the values will always be the same value type objects (with different values). So the columns will be determined (and named) with the strings:
foreach (var kvp in array.GetValue(0) as Dictionary<string, object>)
{
dataGridView_StructArray.Columns.Add(kvp.Key, kvp.Key);
}
So, row will be an element in the array, so each cell will be the object in that array element:
for (int i = 0; i < array.GetLength(0); i++)
{
dataGridView_StructArray.Rows.Add(((Dictionary<string, object>)array.GetValue(i)).Values.ToArray());
}
What I don’t know beforehand is what will dictionaries actually contain.
I want to bind the datagridview to this array, rather than load the datagridview manually as per the code above.
Any suggestions…