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 i开发者_StackOverflow社区tem.
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?
You can set the DrawMode property of your ListBox
control to OwnerDrawVariable and handle its MeasureItem and DrawItem events.
There is a MeasureItem
event. Don't forget to set DrawMode
to OwnerDrawVariable
.
精彩评论