【问题标题】:How to sort DataGridView ascending and descending in C# [duplicate]如何在C#中对DataGridView进行升序和降序排序[重复]
【发布时间】:2016-10-05 13:34:11
【问题描述】:

如何在 C# 桌面应用程序中对 DataGridView 进行升序和降序排序?

我刚刚将列表映射到数据网格视图源

List<Lecturer> lecList = new Lecturer().getAllLecturers();
   dgvLecturer.DataSource = lecList;

【问题讨论】:

  • 您还可以在将列表绑定到 DataGrid 之前对其进行排序:例如:lecList.OrderBy(x=&gt;x.Id);lecList.OrderByDescending(x=&gt;x.Id);,然后将其传递给 DataSource。

标签: c# sorting datagridview


【解决方案1】:

【讨论】:

  • 我已经试过了,id不起作用:(
  • 我收到此错误“DataGridView 控件必须绑定到要排序的 IBindingList 对象”。
猜你喜欢
  • 2020-06-06
  • 2015-08-30
  • 2020-11-09
  • 2016-03-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-08-24
  • 2021-06-25
相关资源
最近更新 更多