是否有可能复杂类型的属性绑定到DataGrid? [英] Is it possible to bind complex type properties to a datagrid?
问题描述
我怎么会去结合下面的对象,汽车,到GridView?
How would I go about binding the following object, Car, to a gridview?
public class Car
{
long Id {get; set;}
Manufacturer Maker {get; set;}
}
public class Manufacturer
{
long Id {get; set;}
String Name {get; set;}
}
原始类型坐上开往容易,但我没有发现任何方式显示何事机的。我想它来显示Manufacturer.Name。它甚至有可能?
The primitive types get bound easy but I have found no way of displaying anything for Maker. I would like for it to display the Manufacturer.Name. Is it even possible?
什么是一个办法做到这一点?我本来存储ManufacturerId在汽车以及再设置一个lookupEditRepository与制造商的列表?
What would be a way to do it? Would I have to store ManufacturerId in Car as well and then setup an lookupEditRepository with list of Manufacturers?
推荐答案
是的,你可以创建一个TypeDescriptionProvider来实现嵌套的结合。下面是一个MSDN博客中详细的例子:
Yes, you can create a TypeDescriptionProvider to accomplish nested binding. Here is a detailed example from an MSDN blog:
<一个href="http://blogs.msdn.com/msdnts/archive/2007/01/19/how-to-bind-a-datagridview-column-to-a-second-level-property-of-a-data-source.aspx">http://blogs.msdn.com/msdnts/archive/2007/01/19/how-to-bind-a-datagridview-column-to-a-second-level-property-of-a-data-source.aspx
这篇关于是否有可能复杂类型的属性绑定到DataGrid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!