views:

33

answers:

1

Hi,

I face the following problem. I want to bind a C# struct with least effort to a grid control. The grid control should show the struct members (the variable names and the value strored in the variable) i.e. let's say I have a struct like the following struct A { string name; int value; }

A.name="huhu"; A.value=3;

I would want to have the grid control showing the following content (2 columns, 2 rows) - similar to the watch window content in VS2010 i.e. name, huhu value, 3

How would I achieve this with minimal effort? Or do I have to go the "full way" and use reflection to parse the struct, create a list of string-pairs & bind this list to the grid-control.

regards Johannes

A: 

I think you would have to manually do the stuff with reflection. Even if the grid was able to display the values as strings, you would still need to create the datasource by hand, because it cannot bind to a Type object.

Slavo