【问题标题】:Sorting DataGridView排序 DataGridView
【发布时间】:2023-03-23 20:23:01
【问题描述】:

我已将 DataGridView 的列设置为 SortMode = DataGridViewColumnSortMode.Automatic; 但是单击单元格标题时,它不会对其进行排序

Deos 有人知道怎么做吗?

【问题讨论】:

  • 你的专栏有SortExpression吗?
  • 我刚刚为每一列写了 column.sortmode = DataGridViewColumnSortMode.Automatic;我对 SortExpression 一无所知

标签: c# datagridview


【解决方案1】:

datagridview中有一个方法Sort

dataGridView1.Sort(dataGridView1.Columns["yourcol"],ListSortDirection.Ascending);

【讨论】:

    【解决方案2】:

    您的数据源必须是可排序的

    DataTable/DataView 是可排序的

    列表本身不可排序(按属性)

    看看这里:http://www.codeproject.com/Articles/31418/Implementing-a-Sortable-BindingList-Very-Very-Quic

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-18
      • 2014-03-28
      • 2013-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-23
      相关资源
      最近更新 更多