gpt4 book ai didi

delphi - 带有复选框和子项图像的 TListView

转载 作者:行者123 更新时间:2023-12-02 02:52:02 27 4
gpt4 key购买 nike

使用标准 TListView 组件 (ViewStyle = vsReport),我附加了一个 TImageList 并成功将图像添加到第一列 (Item.ImageIndex := 0) )以及后续列 (Items[0].SubItemImages[1] := 1)。

如果我随后将 CheckBoxes 属性设置为 True,子项上的图像就会消失。主图像保留(由 Item.ImageIndex 设置的图像),但子项丢失其图像。

我还注意到,当 CheckBoxes = True 时,OnGetSubItemImage 事件不会触发

有人知道解决这个问题的方法吗?

最佳答案

这是一个非常古老的错误,当您激活 CheckBoxes 属性时会禁用 LVS_EX_SUBITEMIMAGES 并TListView 控件上的 LVS_EX_INFOTIP 样式。

您可以使用此解决方法来修复此错误。

1)禁用 ListView 中的复选框属性

2) 将此代码(在 Delphi 7 和 Windows 7 中测试)放入您的表单中。

const
LVM_FIRST =$1000;
LVS_EX_SUBITEMIMAGES = $00000002;
LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54;
LVM_GETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 55;


function ListView_GetExtendedListViewStyle(LVWnd: HWnd): DWORD;
begin
Result := SendMessage(LVWnd, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
end;

function ListView_SetExtendedListViewStyle(LVWnd: HWnd; ExStyle: LPARAM): DWORD;
begin
Result := SendMessage(LVWnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ExStyle);
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
ListView1.Checkboxes:=True;//Activate the checkbox in the listview
ListView_SetExtendedListViewStyle(ListView1.Handle,ListView_GetExtendedListViewStyle(ListView1.Handle) OR LVS_EX_SUBITEMIMAGES); //Activate the LVS_EX_SUBITEMIMAGES style.
end;

3) 最终结果为

alt text

关于delphi - 带有复选框和子项图像的 TListView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2335615/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com