ListView排序 [英] ListView sort

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

问题描述

ListView是否支持排序?

我希望有一个向上/向下箭头/三角形,表示它在列标题上排序为asc或desc

当我点击列标题。

我可能需要第三方组件吗?

Does the ListView supports sort?
I want to have a up/down arrow/triangle that show it is sorted asc or desc
on the column headers when I click the column header.
May be I need a third-party components ?

推荐答案

使用.NET 2.0,你可以完成所有这些。


- 您可以为ListView的每个ColumnHeader分配一个图标。你只需要添加一个ArrowUp,ArrowDown即可。和一个SpacerIcon (一个完全

透明图标)到ListView的Imagelist,并根据你的排序顺序选择正确的

ImageIndex和女巫数据栏目

排序。


- 你可以制作自己的ListViewItemSorter (实现

ICompare的对象)并将其分配给ListView.ListViewItemSorter以按照您想要的方式对ListView

进行排序。


Steph。



" Alan T" < al ************* @ yahoo.com.auwrote in message

news:e4 ************** @ TK2MSFTNGP03.phx.gbl ...
With .NET 2.0 you can do all of that.

- You can assign an icon to each ColumnHeader of the ListView. You
just need to add an "ArrowUp", "ArrowDown" and one "SpacerIcon" (a fully
transparent Icon) to the Imagelist of the ListView, and select the right
ImageIndex according to your sorting order and the column on witch data are
sorted.

- You can make your own "ListViewItemSorter" (object that implement
ICompare) and assign it to ListView.ListViewItemSorter to sort the ListView
the way you want.

Steph.



"Alan T" <al*************@yahoo.com.auwrote in message
news:e4**************@TK2MSFTNGP03.phx.gbl...

ListView是否支持排序?

我想要一个上/下箭头/三角形当我点击列标题时,显示它在列标题上排序为asc或desc



我可能需要第三方组件吗?

Does the ListView supports sort?
I want to have a up/down arrow/triangle that show it is sorted asc or desc
on the column headers when I click the column header.
May be I need a third-party components ?



不需要SpacerIcon。只需将图像索引设置为-1即可删除

图像

顺便说一下,此技术也可以在1.1中使用。唯一的区别是

你需要P / Invoke来设置图像索引并将图像列表分配给

标题。


/ claes


" TheSteph" < Th ****** @ NoSpam.com写信息

新闻:%2 **************** @ TK2MSFTNGP05.phx.gbl。 ..
No need for a "SpacerIcon". Just set the image index to -1 to remove the
image
Btw, this technique can be used in 1.1 as well. Only difference is that
you''ll need P/Invoke to set the image index and to assign the image list to
the header.

/claes

"TheSteph" <Th******@NoSpam.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...

使用.NET 2.0,您可以完成所有这些。


- 您可以为每个ColumnHeader分配一个图标ListView。你只需要添加一个ArrowUp,ArrowDown即可。和一个SpacerIcon (完全

透明图标)到ListView的图像列表,并根据您的排序顺序和女巫数据列选择正确的

ImageIndex



排序。


- 您可以制作自己的ListViewItemSorter (对象

实现

ICompare)并将其分配给ListView.ListViewItemSorter以对

ListView进行排序

你想要的方式。


Steph。



" Alan T" < al ************* @ yahoo.com.auwrote in message

news:e4 ************** @ TK2MSFTNGP03.phx.gbl ...
With .NET 2.0 you can do all of that.

- You can assign an icon to each ColumnHeader of the ListView. You
just need to add an "ArrowUp", "ArrowDown" and one "SpacerIcon" (a fully
transparent Icon) to the Imagelist of the ListView, and select the right
ImageIndex according to your sorting order and the column on witch data
are
sorted.

- You can make your own "ListViewItemSorter" (object that
implement
ICompare) and assign it to ListView.ListViewItemSorter to sort the
ListView
the way you want.

Steph.



"Alan T" <al*************@yahoo.com.auwrote in message
news:e4**************@TK2MSFTNGP03.phx.gbl...

> ListView是否支持排序?
我想要一个上/下箭头/三角形来显示它当我点击列标题时,在列标题上排序为asc或
desc

我可能需要第三方组件吗?

>Does the ListView supports sort?
I want to have a up/down arrow/triangle that show it is sorted asc or
desc
on the column headers when I click the column header.
May be I need a third-party components ?




是否有方法对每列进行排序?


" Claes Bergefall" < lo ***** @ nospam.nospamwrote in message

news:OA ************** @ TK2MSFTNGP04.phx.gbl ...
Is there a method to sort each column ?

"Claes Bergefall" <lo*****@nospam.nospamwrote in message
news:OA**************@TK2MSFTNGP04.phx.gbl...

不需要SpacerIcon。只需将图像索引设置为-1即可删除

图像

顺便说一下,此技术也可以在1.1中使用。唯一的区别是

你需要P / Invoke来设置图像索引并将图像列表

分配给标题。

/ claes


" TheSteph" < Th ****** @ NoSpam.com写信息

新闻:%2 **************** @ TK2MSFTNGP05.phx.gbl。 ..
No need for a "SpacerIcon". Just set the image index to -1 to remove the
image
Btw, this technique can be used in 1.1 as well. Only difference is that
you''ll need P/Invoke to set the image index and to assign the image list
to the header.

/claes

"TheSteph" <Th******@NoSpam.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...

>使用.NET 2.0,您可以完成所有这些。

- 您可以为每个ColumnHeader分配一个图标ListView。
你只需要添加一个ArrowUp,ArrowDown即可。和一个SpacerIcon (一个完全
透明的图标)到ListView的Imagelist,并根据你的排序顺序选择正确的ImageIndex,并对女巫数据栏目进行排序。

- 您可以制作自己的ListViewItemSorter (
实现ICompare的对象)并将其分配给ListView.ListViewItemSorter以按照您想要的方式对ListView进行排序。

Steph。


Alan T < al ************* @ yahoo.com.auwrote in message
新闻:e4 ************** @ TK2MSFTNGP03.phx。 gbl ...
>With .NET 2.0 you can do all of that.

- You can assign an icon to each ColumnHeader of the ListView.
You
just need to add an "ArrowUp", "ArrowDown" and one "SpacerIcon" (a fully
transparent Icon) to the Imagelist of the ListView, and select the right
ImageIndex according to your sorting order and the column on witch data
are
sorted.

- You can make your own "ListViewItemSorter" (object that
implement
ICompare) and assign it to ListView.ListViewItemSorter to sort the
ListView
the way you want.

Steph.



"Alan T" <al*************@yahoo.com.auwrote in message
news:e4**************@TK2MSFTNGP03.phx.gbl...

>> ListView是否支持排序?
我想要一个向上/向下箭头/三角形,表明它已排序单击列标题时,列标题上的asc或
desc

我可能需要第三方组件吗?

>>Does the ListView supports sort?
I want to have a up/down arrow/triangle that show it is sorted asc or
desc
on the column headers when I click the column header.
May be I need a third-party components ?





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

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