views:

41

answers:

2

I'm used to display multiple objects with a DataGridView control in the following format

ID     Name     Address      [...]
ID1    Name1    123 street   [...]
ID2    Name2    456 street   [...]

This is simple to do with objects, properties and a BindingList<>.

I'd like my data to be "rotated" 90 degrees so that the grid displays a key:value pair such as

FieldName     Value
ID            ID1
Name          Name1
Address       123 street

Is this possible to achieve by binding some kind of list/dictionnary/other to the DataSource? I'm checking this approach because the object properties get/set makes it MUCH easier to handle data changes than handling a gazillion events exported from the DataGridView

+1  A: 

It sounds to me like you would want to just use FormView or DetailsView? (Main difference is DetailsView gives you auto generated tables, with FormView you define a template)

If those aren't the answer, can you explain why you need to stick with DataGridView in particular?

David Eison
+1  A: 

Is this a Windows Forms application? Have you considered using a PropertyGrid? It seems to me to be the natural choice for your problem unless you're doing an ASP.Net app.

cncore