If I'm not mistaken, it shows the result of calling .ToString() on your subObject, so you can override that to return the contents of Description.
Have you tried just binding to Value1.Description? (I'm guessing it doesn't work).
I have a class that can be used instead of List when binding, that will handle this, it implements ITypedList, which allows a collection to provide more "properties" for its objects, including calculated properties.
If no easy solution crops up, I'll post a link to my repository later when I'm at my home computer.
Edit: Ok, the current version of the files I have are here:
http://code.google.com/p/lvknet/source/browse/#svn/trunk/LVK/Collections
Depending on your browser you will get either a warning or an error message saying something about the certificate. The reason is that the certificate doesn't match the url and I'm too lazy to try to figure out if there is something I can do about it. It's a subversion repository so nothing malicious should be there but the usual guidelines are in effect.
You'll need a username and password, both are guest in lower-case.
The files you want are the ones near the bottom of that list, TypedList*.
Unfortunately (for you), I tend to write classes and code in that class library by reusing other bits I have already written, so you'll need to download the first few files and if those doesn't compile, either try taking something out or grab a few more files. There are namespaces and such further up the hierarchy if you need them.
To use:
List<rootClass> yourList = ...
TypedListWrapper<rootClass> bindableList = new TypedListWrapper<rootClass>(yourList);
bindableList.BindableProperties = "Value1;Value2.Description;Value3.Description";
gridView1.DataSource = bindableList;
Basically you bind to an instance of TypedList<T>
instead of List<T>
, and adjust the BindableProperties property. I have some changes in the work, including one that just builds up BindableProperties automatically as it goes, but it isn't in the trunk yet.
You can also add calculated properties, like this:
yourList.AddCalculatedProperty<Int32>("DescriptionLength",
delegate(rootClass rc)
{
return rc.Value2.Description.Length;
});
or with .NET 3.5:
yourList.AddCalculatedProperty<Int32>("DescriptionLength",
rc => rc.Value2.Description.Length);