如何在C#中的ResourceSet排序 [英] How to sort ResourceSet in C#

查看:134
本文介绍了如何在C#中的ResourceSet排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有filetypes.resx命名的资源文件。一些如何我想通了绑定的资源值到DropDownList的,但我不知道怎么的值进行排序的的ResourceSet

I have a resource file named filetypes.resx. Some how I figured out to bind the resource values to dropdownlist, but I don't know how to sort the values of ResourceSet.

下面是我做的,到目前为止,

Here is what I did so far,

FileTypes.resx


  • 名称,值

  • A,1

  • Name,Value
  • A,1

b,2

C,3

代码绑定的DropDownList


DropDownList1.DataSource = Resources.FileTypes.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true);
DropDownList1.DataTextField = "Key";
DropDownList1.DataValueField = "Value";
DropDownList1.DataBind();



结果

Result


 A
 C
 B



As you can see the result is not sorted. Please help me to solve this issue.

在预先感谢:)

推荐答案

本的ressource集都有一个IDictionaryEnumerator,所以我想它的项目类型的DictionaryEntry,尽量像这样的数据源进行排序:

The ressource set has a IDictionaryEnumerator so I guess that its items are of type DictionaryEntry, try to sort the data source like this :

DropDownList1.DataSource = Resources.FileTypes.ResourceManager
    .GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, true, true)
    .OfType<DictionaryEntry>()
    .OrderBy(i => i.Value);



呜呜,我也没有视觉工作室打开,不要怪我的情况下,它不会立刻工作:)

Hum, I have no visual studio opened so don't blame me in case it does not work immediatly :)

这篇关于如何在C#中的ResourceSet排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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