如何在dataGridView列排序后将某些行保持在同一位置 [英] how to keep certain rows in same position after dataGridView column sort

查看:70
本文介绍了如何在dataGridView列排序后将某些行保持在同一位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理dataGridView,我正在应用自定义排序......如何维护某些行位置?例如,如果我有一个包含20行的网格,并且我希望行(2,5,15)保持在相同的位置,我该如何解决这个问题?

解决方案

< blockquote>如果你使用这种排序方法,你可以这样做:

http:/ /msdn.microsoft.com/en-us/library/wstxtkxs.aspx [ ^ ]。



您需要提供 System.Collections的特殊实现。 IComparer http://msdn.microsoft.com/en -us / library / system.collections.icomparer.aspx [ ^ ],所以它会提供一些自定义排序。



不要尝试这样做。它打败了排序的目的,会非常非常混乱。相反,正确设计UI。



-SA


I''m working on a dataGridView and I''m applying custom sorting...how do I maintain certain row position? For example, if I have a grid with 20 rows and I want rows (2,5,15) to stay in their same positions how do I go about this?

解决方案

You could do it if you use this sorting method:
http://msdn.microsoft.com/en-us/library/wstxtkxs.aspx[^].

You would need to provide a special implementation of System.Collections.IComparer, http://msdn.microsoft.com/en-us/library/system.collections.icomparer.aspx[^], so it would provide some custom sorting.

Don''t try to do it. It defeats the purpose of sorting and would be very, very confusing. Instead, design UI properly.

—SA


这篇关于如何在dataGridView列排序后将某些行保持在同一位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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