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.
The key MSDN topic is that for the HDITEM
struct.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…