【问题标题】:Sortable BindingList for custom column自定义列的可排序 BindingList
【发布时间】:2018-01-10 12:35:39
【问题描述】:

我有一个数据绑定到 BindingList 的 DataGridView。我的 DataGridView 还添加了几个自定义列。这些不是数据绑定的,而是基于我的 BindingList 中的项目生成的 (即:我的 BindingList 中的 A 类型的项目具有 B 类型的属性;我的自定义列显示 B.Name 在这种情况下,“名称”是 B 类的属性,因此列所代表的属性不会直接在 BindingList 中的项目中找到。

谁能帮我解决这个问题? 我想让它通用

例如

public class Fruits
{
  public String Id {get;set}
  public String Name {get;set}
}

public class People
{
  public String ID {get;set}
  public String Name {get;set}
  public Fruits FavouriteFruit{get;set}
}

在 BindingList 中,我们可以在 DatagridView 中对 People 上的属性使用自定义可排序列表进行排序,但是,我还想根据 FavouriteFruit 对 People 进行排序。

【问题讨论】:

  • 我不确定,但我猜您需要将列(和数据)添加到基本数据源中。

标签: c# winforms datagridview bindinglist


【解决方案1】:

您可以继承 DataGRidView 并添加所需的属性。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-14
    • 2017-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-06
    • 1970-01-01
    相关资源
    最近更新 更多