ListView中的项目间距,其中View = List [英] Item spacing in ListView where 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 theForm
- Set its
ImageSize.Height
to the height you want - Set the
ListView
'sSmallImageList
to theImageList
完成.
注意:
- 您不需要无需在任何
Item
上设置ImageIndex
. - 您不需要添加任何
图片
.
- You do not need to set the
ImageIndex
on anyItem
. - 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屋!