如何显示上的TListView列的排序箭头? [英] How to show the sort arrow on a TListView column?

查看:627
本文介绍了如何显示上的TListView列的排序箭头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Windows资源管理器有一个箭头指示哪个列的列表视图(在报表视图风格)由在哪个方向(ASC与DESC)排序。

Windows Explorer has an arrow indicating which column a list view (in report view style) is sorted by and in which direction (ASC vs. DESC).

是否有可能在德尔福显示在的TListView 这样的排序指示箭头?

Is it possible to display such a sort indication arrow on a TListView in Delphi?

推荐答案

下面是一些简单的code标记的标题列按升序进行排序:

Here's some simple code to mark a header column as sorted ascending:

uses
  Winapi.CommCtrl;

var
  Header: HWND;
  Item: THDItem;
begin
  Header := ListView_GetHeader(ListView1.Handle);
  ZeroMemory(@Item, SizeOf(Item));
  Item.Mask := HDI_FORMAT;
  Header_GetItem(Header, 0, Item);
  Item.fmt := Item.fmt and not (HDF_SORTUP or HDF_SORTDOWN);//remove both flags
  Item.fmt := Item.fmt or HDF_SORTUP;//include the sort ascending flag
  Header_SetItem(Header, 0, Item);
end;

我已被删去错误检查简单起见。如果你想在相反方向的箭头,我敢肯定,你可以工作如何围绕交换逻辑。

I have omitted error checking for the sake of simplicity. If you want the arrow in the opposite direction, I'm sure you can work out how to swap the logic around.

关键MSDN主题是,对于 HDITEM 结构。

The key MSDN topic is that for the HDITEM struct.

这篇关于如何显示上的TListView列的排序箭头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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