zoukankan      html  css  js  c++  java
  • DataGrid PCV排序学习

    最近工作中,使用到PCV排序,对PCV排序进行了简单的总结。

    一般情况下,对结果集进行简单排序,我会直接使用OrderBy方法,如:

    PagedCollectionView pcv = new PagedCollectionView(List.OrderByDescending(p=>p.rzdh));//融资单号排序

    如果想要更复杂的排序,怎么办?比如要先按A升序,再B降序,再按C......,这就要使用新的方法。

    ICollectionView接口定义了一个SortDescriptions集合,用以设置视图的排序规则,我们可以通过添加多个SortDescription对象来完成这种复合排序需求。如:

    #region 通过PCV针对集合进行排序
    PagedCollectionView pcv = new PagedCollectionView(List);
    pcv.SortDescriptions.Clear();
    var sortDescription1 = new System.ComponentModel.SortDescription("rzdh", System.ComponentModel.ListSortDirection.Descending);//融资单号降序
    var sortDescription2 = new System.ComponentModel.SortDescription("zdrq", System.ComponentModel.ListSortDirection.Ascending);//制单日期升序
    pcv.SortDescriptions.Add(sortDescription1);
    pcv.SortDescriptions.Add(sortDescription2);
    #endregion

    总结如上,继续学习。

  • 相关阅读:
    No.2 对象与内存控制(内存分配)
    No.1 数组与内存控制
    Json解析 在VS中
    MVC 搜索防止点击其他按钮
    执行多个lanmada表达式查询
    删除重复数据
    分页
    DataSet与二进制文件和XML文件
    关于时间的转换
    转换人民币大小金额
  • 原文地址:https://www.cnblogs.com/prolovecui/p/4629417.html
Copyright © 2011-2022 走看看