简体   繁体   English

Delphi,ListView,如何删除vsIcon中项之间的边距

[英]Delphi, ListView, how to remove the margin between items in vsIcon

Using Delphi XE3, Listview in vsIcon mode with an imagelist assigned. 在vsicon模式下使用Delphi XE3,Listview并指定了imagelist。

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? 我添加一些项目并为它们分配一个ImageIndex,每个图像/项目之间有一个非常大的间距/边距,我该如何改变它? Is it possible at all without custom drawing? 没有定制绘图可以吗?

You can use ListView_SetIconSpacing macro 您可以使用ListView_SetIconSpacing

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: 您可以通过为cx和cy发送'-1'来重置视图,并且返回值是当前间距,因此,例如,要减少一定量的间距,您可以执行以下操作:

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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM