Using the standard TListView component (ViewStyle = vsReport
), I have attached a TImageList and have successfully added images to both the first column (Item.ImageIndex := 0
) and to the subsequent columns (Items[0].SubItemImages[1] := 1
).
If I then set the CheckBoxes property to True, the images on SubItems disappear. The main image remains (the one set by Item.ImageIndex
) but the SubItems lose开发者_如何转开发 their images.
I have also noticed that the OnGetSubItemImage
event doesn't fire when CheckBoxes = True
Does anyone know of a way around this?
this is a very old bug, when you activate the CheckBoxes property would disable the LVS_EX_SUBITEMIMAGES and LVS_EX_INFOTIP styles on the TListView control.
you can use this workaround for fix this bug.
1) Disable the checkbox property in the listview
2) Put this code (Tested in Delphi 7 and windows 7) in your form .
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) and the final result is
Well this doesn't help particularly, but the TMS TAdvListView component handles it with its SubImages
property. Set this to True and I can have Checkboxes and sub item images. I'm sure there's a lot of good work going on behind the scenes. At least this moves me forward.
精彩评论