排序列表< DataRowView>一栏 [英] Sort List<DataRowView> by a column

查看:75
本文介绍了排序列表< DataRowView>一栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好


我有一个绑定到DataTable的BindingSource


然后我用所有的填充DataRowView(MyList)列表来自BindingSource的行。


现在我需要使用特定的列索引对MyList进行排序 


如何做?


注意,我无法对BindingSource进行排序,因为MyList是另一个对象的属性


解决方案

您是否尝试过这样的代码? :
'sorted_list = MyList.OrderBy(r => r [columnIndexOrName])。ToList()'




Hi all

I Have a BindingSource bound to DataTable

Then I fill a List of DataRowView (MyList) with all the rows coming from BindingSource.

Now I need to sort MyList with a specific Column index 

How to do that ?

Note, I cannot sort BindingSource since MyList is a property of another object

解决方案

Did you try a code like this: ‘sorted_list = MyList.OrderBy( r => r[columnIndexOrName] ).ToList()’?



这篇关于排序列表< DataRowView>一栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆