Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Winforms: How to create a listbox with variable item height

I need a simple listbox control where height for each item varies. And then i to need draw a custom image for each item.

Basically item_height would be equal to (listbox_width / image_width ) * image_height.

Normally I would just take a listbox and specify on paint event, but i need a variable height for each item.

Is there a simple way to get a list box with items of variable height?

like image 763
JBeurer Avatar asked Nov 20 '10 18:11

JBeurer


2 Answers

You can set the DrawMode property of your ListBox control to OwnerDrawVariable and handle its MeasureItem and DrawItem events.

like image 140
Frédéric Hamidi Avatar answered Sep 28 '22 10:09

Frédéric Hamidi


There is a MeasureItem event. Don't forget to set DrawMode to OwnerDrawVariable.

like image 27
max Avatar answered Sep 28 '22 10:09

max