基础设施价值列表排序

发布于 2024-10-24 17:53:10 字数 406 浏览 5 评论 0原文

场景如下:

我有一个类型为“Infragistics.Win.ValueList”的值列表。我想对值列表进行排序。假设我在值列表中有以下值。

“值1” “值3”。 “价值2” “价值11” “值 22”

我正在使用“value-list.SortStyle = ValueListSortStyle.Ascending;”按升序对值列表进行排序。输出如下:

“值1” “价值11” “价值2” “价值22” “值3”。

这是因为排序是基于字符串的,而所需的输出是

“Value 1” “价值2” “价值3” “价值11” “值22”。

另外,ValueList 不公开 SortComparer 属性,因此我可以编写自定义排序。

我应该采取什么方法来获得所需的输出?

Scenatio is as follows:

I have a value-list which is of Type "Infragistics.Win.ValueList". and I want to sort the value-list. Let say I have the following values in Value-list.

"Value 1"
"Value 3".
"Value 2"
"Value 11"
"Value 22"

I'm using "value-list.SortStyle = ValueListSortStyle.Ascending;" to sort the value-list in ascending order. The output is as follows:

"Value 1"
"Value 11"
"Value 2"
"Value 22"
"Value 3".

This is becasue the sorting is based on string, where as the desired output is

"Value 1"
"Value 2"
"Value 3"
"Value 11"
"Value 22".

Also, ValueList doesn't expose the SortComparer property, so that I can write custom sort.

What should be my approach to get the desired output?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酒中人 2024-10-31 17:53:10

是否还有与您的每个值相关的其他属性?值列表上有“值”和“文本”属性,因此如果您能找到更好的东西放入“值”列中,我想这可能是理想的选择?

如果没有,您可能可以使用 UltraDropDown / UltraCombo 而不是值列表。它们就像迷你 UltraGrids,所以您应该能够将自定义排序应用到其中一个,就像在网格上一样(不是 100% 确定,但我在这台计算机上没有 Infragistics,所以我明天会在工作中检查)。

Is there another property associated to each of your values? There are 'Value' and 'Text' properties on the value lists so if you could find something that sorts better to put in the 'Value' column I guess that might be ideal?

If not you could probably use an UltraDropDown / UltraCombo instead of a value list. They are like mini UltraGrids so you should be able to apply the custom sort to one of those the same as you would on a grid (not 100% sure but I don't have Infragistics on this computer so I'll check at work tomorrow).

蓝眼泪 2024-10-31 17:53:10

不过我已经找到了解决方案。这绝对不是最好的解决方案,但它给了我想要的输出。这里是。

将值存储在值列表中后,我将所有值分配给 ArrayList(仅 Text 属性)。然后我对 ArrayList 进行排序,它公开了 SortComparer 属性。

I have found a solution though. It is definately not the best solution, but its giving me the desired output. Here it is.

After the values are stored in the value list I'm assinging the assinging all the values to a ArrayList(only the Text property). Then I'm sorting the ArrayList, which exposes the SortComparer property.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文