将DataGridView数据绑定到具有另一个列表作为属性的自定义类的列表

时间:2011-01-17 18:57:41

标签: c# winforms data-binding datagridview

  

可能重复:
  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  |      |        |        |                 |                 |
...   |      |        |        |                 |                 |

这可能吗?如果是这样,将如何实施?

0 个答案:

没有答案
相关问题