ListView中的项目间距,其中View = List [英] Item spacing in ListView where View=List

查看:35
本文介绍了ListView中的项目间距,其中View = List的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带复选框和view = list的listview.项目之间根本没有垂直间距.如何增加垂直间距?

I have a listview with checkboxes and the view=list. There is no vertical spacing at all between the items. How can I increase the vertical spacing?

很多答案都在谈论LVM_SETICONSPACING,但这仅在图标"视图中有效.在此处查看答案

A lot of answers are talking about LVM_SETICONSPACING, but that only works in Icon view. Check Answer here

我还尝试了 BetterListview Express ,但是这样做的空间太大,以至于另一个物品可能会介于两者之间,在快速模式下,您不能更改间距,只能在300美元的付费版本中...:(

I also tried BetterListview express as an alternative, but that gives so much spacing that another item could go in between, in Express mode you cannot change the spacing, only in the 300 Dollar paid version... :(

推荐答案

所有您需要做的就是

  • ImageList 添加到 Form
  • 将其 ImageSize.Height 设置为所需的高度
  • ListView SmallImageList 设置为 ImageList
  • Add an ImageList to the Form
  • Set its ImageSize.Height to the height you want
  • Set the ListView's SmallImageList to the ImageList

完成.

注意:

  • 不需要无需在任何 Item 上设置 ImageIndex .
  • 不需要添加任何图片.
  • You do not need to set the ImageIndex on any Item.
  • You do not need to add any Images.

请确保将 ImageSize.Width 设置为一个较小的数字,以免在 CheckBox Item 的 Text .

Make sure to set the ImageSize.Width to a small number, so you don't get a gap between the CheckBox and the Item's Text.

因此要设置 ListView 编写:

int itemHeight = 20;
ImageList imgList = new ImageList();
imgList.ImageSize = new Size(1, itemHeight);
listView1.SmallImageList = imgList;

这篇关于ListView中的项目间距,其中View = List的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆