C# Change ListView Item's/Row's height

Ron picture Ron · Jul 3, 2011 · Viewed 69.9k times · Source

I want to change the Item's/Row's height in listview.

I searched every where and I figured that in order to change the height I need to use LBS_OWNERDRAWFIXED or MeasureItem or something like that.

The problem is that I dont know exactly what to do and how to use it..
Can anyone help me with it?

Edit:
I cant use the ImageList hack because I am using the SmallImageList for real and I need different line height from the ImageList images size.

Thanks!

Answer

Maarten Peels picture Maarten Peels · Feb 6, 2015

For the people that are still struggling with this, here is the code I use:

private void SetHeight(ListView listView, int height)
{
    ImageList imgList = new ImageList();
    imgList.ImageSize = new Size(1, height);
    listView.SmallImageList = imgList;
}

To use this, just do:

SetHeight(lvConnections, 25);