它对排字符是可以的,但是我想排数字,要求它对数字敏感。如:1000
20
11
32要求它排成
11
20
32
1000
而它只能排成
1000
11
20
32我愿意高分相送。
20
11
32要求它排成
11
20
32
1000
而它只能排成
1000
11
20
32我愿意高分相送。
解决方案 »
- delphi如何输出FastReport的pdf文档
- 关于CheckListBox的一个菜菜的问题
- SQLServer数据库字段设为何种类型,才能被DBCheckBox正确显示?
- 有没有人知道delphi嗅探器怎么写?
- 大侠,如何判断一个点和弧线相交
- Win2000上,不能用自定义报表的,怎么办?发现所有打印机都不没有自定义这一选项,所认,我们的Quickrep做的报表都不能打印自定义纸张!
- 关于图象透明问题
- 哪里有delphi消息处理机制的资料下载?
- 这个SQL语名该怎么写呢?急!急!急!急!急!急!急!急!
- update table set string_field=string_field+'my home' 出现错误?
- 一个关于存储过程的问题
- 请问各位大侠:如何在delphi中实现窗口得四个边角为圆弧形?
在你的单元接口段的private下声明:
columntosort:integer;
isascsort:boolean;在ListView的ColumnClick事件里给columntosort赋值(被单击列的索引号),调用AlphaSort:
procedure TForm1.ListView1ColumnClick(Sender: TObject;
Column: TListColumn);
begin
isascsort:=not isascsort;
columntosort:=column.Index;
(sender as tcustomlistview).AlphaSort;
end;然后在ListView的Compare事件里写排序代码:procedure TForm1.ListView1Compare(Sender: TObject; Item1, Item2: TListItem;
Data: Integer; var Compare: Integer);
var
xx:integer;
begin
if columntosort=0 then//按标题列排序;
if isascsort then
compare:=comparetext(item1.Caption,item2.Caption)
else
compare:=comparetext(item2.Caption,item1.Caption)
else//按SubItems排序
begin
xx:=columntosort-1;
if isascsort then
compare:=comparetext(item1.SubItems[xx],item2.SubItems[xx])
else
compare:=comparetext(item2.SubItems[xx],item1.SubItems[xx]);
end;
end;以上须注意排序原理,相应函数可查DELPHI帮助.
问题解决了吧,还有多少分送啊!:)