可能重复:
WinForms DataGridView - databind to an object with a list property (variable number of columns)
我有DataGridView
绑定到自定义类的List
。我的自定义类如下:
Class Example
{
public string Name;
public double Height;
public double Length;
public List<double> ExtraColumns;
}
我希望我的DataGridView将自定义类的属性显示为列,并为List<double> ExtraColumns
属性中的每个项显示一个附加列。换句话说,当我将其绑定到List<Example>
:
| Name | Height | Length | ExtraColumns[0] | ExtraColumns[1] | ...
--------------------------------------------------------------------
row1 | | | | | |
row2 | | | | | |
row3 | | | | | |
... | | | | | |
这可能吗?如果是这样,将如何实施?