【问题标题】:Binding an array of objects to DataGridView control将对象数组绑定到 DataGridView 控件
【发布时间】:2020-08-03 13:00:33
【问题描述】:

我有一个基类Product 的数组,其中包含派生类MedicationParapharmaceutical 的对象。

在 DataGridView 控件中,我试图显示所有字段(基类的共同字段以及每个派生类的特定字段)。

dataGridView1.DataSource = ArrayOfProducts;

dataGridView1.ColumnCount = 6;

dataGridView1.Columns[0].Name = "Reference";

...

现在的问题是如何将数组对象的属性绑定到列(对象是不同的类型)?

【问题讨论】:

    标签: c# data-binding datagridview datasource datagridviewcolumn


    【解决方案1】:

    不清楚您想在这里完成什么,但听起来您需要将“ArrayOfProducts”设置为 DataTable 以控制数据的关联具有正确的列和数据类型。这有帮助吗?

    【讨论】:

    猜你喜欢
    • 2012-09-01
    • 1970-01-01
    • 2014-08-18
    • 1970-01-01
    • 1970-01-01
    • 2017-08-30
    • 1970-01-01
    • 2013-01-22
    • 1970-01-01
    相关资源
    最近更新 更多