ListView OwnerDraw height of items

I have a listview with OwnerDraw = true and Details view mode. I want when the list contains 3,4 or 5 items the height of each item to be listview.Height/3 ,4 or 5 without scrolling.

I know that the height of item depends on size of the font.

This doesn't work

 listView.Font = new Font("Arial", listView.Height / nOfItems);

I draw the text at DrawItem event with constant font size: e.Graphics.DrawString(....).


What I do successfully is to adjust the height of the list view by assigning an image list with a dummy image with the appropriate height I want to have.

So e.g. to have rows with each 40 pixel high, I assign an image with 40 pixel height to the list view inside an image list.

You do not have to actually draw the image, it is sufficient to assign it and do owner drawing then. It looks like e.g. the list in the background of this screenshot (it is a CMS I wrote in .NET).

you r right.

actually when you change the ImageSize property in ImageList, i have seen the ImageList goes empty. so for your problem You have to refill the ImageList with desire ImageSize again. try it it could solve your problem.

Need Your Help

HTML: Changing default cursor does not work until pointer is moved

html css

I have an overlayWaitDiv defined as follows with CSS:

How to save and retrieve variables upon screen rotation?

java android

Can someone kindly give me a solution to this and explain how he/she came to that particular solution?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.