Delphi, ListView, how to remove the margin between items in vsIcon
delphi, listview
Solution
You can use `ListView_SetIconSpacing` macro
uses commctrl;
..
ListView_SetIconSpacing(ListView1.Handle, 36, 36);
ListView1.Arrange(arAlignTop); // refresh view
Refer to the documentation, the values must include icon sizes, otherwise the icons overlap each other.
You can reset the view by sending '-1' for cx and cy and the return value is the current spacing, so for instance, to decrease spacing with a certain amount, you can do:
var
Spacing: DWORD;
begin
Spacing := ListView_SetIconSpacing(ListView1.Handle, WORD(-1), WORD(-1));
ListView_SetIconSpacing(ListView1.Handle,
LoWord(Spacing) - 10, HiWord(Spacing) - 6);
ListView1.Arrange(arAlignTop);
Problem
Using Delphi XE3, Listview in vsIcon mode with an imagelist assigned. I add a few items and assign them an ImageIndex, and there is a very large spacing/margin between each image/item, how can I change that? Is it possible at all without custom drawing?