对文本框数据进行排序 [英] Sort Textbox Data

查看:92
本文介绍了对文本框数据进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在VS2008中使用btncmd_click的文本框中的数据排序存在一些问题

我在这样的文本框中有数据

There is a Some Problem with Sort Data in Textbox with btncmd_click in VS2008

I have Data in textbox like this

Michal Jackson<br />
Andy<br />
http://www.dreamincode.net<br />
http://www.microsoft.com<br />
http://yahoo.com<br />
001zune<br />
A one



我想将数据排序为0-9,A-z,就像这样:



I want to Sort Data to 0-9, A-z Like this:

001zune<br />
A one<br />
Andy<br />
http://www.dreamincode.net<br />
http://www.microsoft.com<br />
http://yahoo.com<br />
Michal Jackson



谁能指导我?

有人可以给我一个例子吗?

在此先感谢!!



Can Any one guide me?

Can anybody give me an example?

Thanks in Advance !!

推荐答案

由于您未指定语言,所以您会从我这里获得C#.

创建一个List<string>,向其中添加字符串,然后使用List.Sort()方法.
Since you didn''t specify the language, you get C# from me.

Create a List<string>, add the strings to it, and use the List.Sort() method.


我假设您的文本框是多行的.
因此,您可以获得字符串数组中的所有文本.然后,您可以使用Array.Sort方法并使用已排序的数组重置文本框的文本.

如果您使用的是.Net 3.0或更高版本,则可以使用LINQ对数组进行排序(通过order by关键字).
I assume your textbox is multiline.

So, you can get all the text in an string array. Then, you can make use of Array.Sort method and reset the text of the textbox with the sorted array.

In case you are using .Net 3.0 or above, you can use LINQ to sort the array (through order by keyword).


您可能需要考虑使用列表框而不是编辑控件(文本框).检查您的环境/语言工具/库的文档.基本级别的Win 32 API信息位于此处 [
You may want to consider using a list box instead of an edit control (textbox). Check the documentation for your environment/language tool/library. Basic level win 32 api info is here[^]


这篇关于对文本框数据进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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