博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
DataGrid PCV排序学习
阅读量:7070 次
发布时间:2019-06-28

本文共 845 字,大约阅读时间需要 2 分钟。

最近工作中,使用到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

总结如上,继续学习。

转载于:https://www.cnblogs.com/prolovecui/p/4629417.html

你可能感兴趣的文章
网众设置开机重启服务的命令,才可连接BOOT服务器
查看>>
RHEL6.3 DNS配置详解一 DNS相关概念理解及配置基础
查看>>
Windows环境 和 Linux环境下搭建Qt开发环境
查看>>
简述synchronized和java.util.concurrent.locks.Lock的异同
查看>>
在win2008r2下开启ntp服务
查看>>
我的友情链接
查看>>
SpringMVC源码解析(三)——HandlerAdapter
查看>>
Python执行系统命令的方法
查看>>
动态加载远程Jar的实现方式
查看>>
无线***笔记(一)-《***WPA-PSK加密无线网络》
查看>>
MyEclipse10.1集成SVN
查看>>
Sitemesh和Struts2结合时Filter的配制顺序
查看>>
【python】编程语言入门经典100例--19
查看>>
[tomcat7源码学习]ClassLoader加载Tomcat的依赖
查看>>
解决MySQL Master/Slave 同步出错
查看>>
常用的主机监控Shell脚本
查看>>
CentOS历史版本下载方法
查看>>
[cocos2dx]斗地主制作之洗牌算法
查看>>
javascript 注入实现跨html跨浏览器传参
查看>>
linux 网络基本配置
查看>>