2

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?

Listview spacing

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

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... :(

Community
  • 1
  • 1
Bastiaan
  • 686
  • 1
  • 8
  • 20

2 Answers2

8

All you need to do is

  • Add an ImageList to the Form
  • Set its ImageSize.Height to the height you want
  • Set the ListView's SmallImageList to the ImageList

Done.

Note:

  • You do not need to set the ImageIndex on any Item.
  • You do not need to add any Images.

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.

So to set up the ListView write:

int itemHeight = 20;
ImageList imgList = new ImageList();
imgList.ImageSize = new Size(1, itemHeight);
listView1.SmallImageList = imgList;
TaW
  • 53,122
  • 8
  • 69
  • 111
0

If you are using WPF/XAML you can try something like:

...
<ListView.ItemContainerStyle>
    <Style TargetType="{x:Type ListViewItem}">
        <Setter Property="Margin" Value="2, 2, 2, 2"/>
    </Style>
</ListView.ItemContainerStyle>
...

Change the margin to your needs and the spacing will appear.

k1ll3r8e
  • 729
  • 16
  • 22