Solution for 255 limitation of ListBox item height?

  • Thread starter Thread starter Sin Jeong-hun
  • Start date Start date
S

Sin Jeong-hun

Hi.
I have used ListBox's to display some data. I used onwer draw to
present items in various colors and in different heights in accordance
with their size. Everything is fine except that the maximum item
height is 255. Why should this limitation exist? For some items, I
need more than 255 pixels of height. What options do I have? Should I
write my own ListBox class from scratch?

Thank you for any hints.
 
Hi.
I have used ListBox's to display some data. I used onwer draw to
present items in various colors and in different heights in accordance
with their size. Everything is fine except that the maximum item
height is 255. Why should this limitation exist? For some items, I
need more than 255 pixels of height. What options do I have? Should I
write my own ListBox class from scratch?

Thank you for any hints.

Hi,


I was not aware of this limitation in the first place.

255 is VERY big though.
Have you try using other control? like ListView or even a
DataGridView ?
 
I don't know why the limit exists.  I admit, I didn't even realize it  
did.  Possibly a legacy thing, from when storing item heights in 8 bits 
was an important memory optimization.

You may want to reconsider the value of having items larger than 255  
pixels in a ListBox.  That's a lot of screen real-estate for something  
being presented as a single item in a larger list.  But, if you insist, 
you might look at the ListView class instead.  It has similar  
functionality, but is visually the more robust of the two classes (ListBox  
is more data-oriented) and so might support larger items.

Pete

Thank you. ListView has many additional features than ListBox does,
and therefore, I thought it would took more resources. I didn't need
anything advanced but a simple list with various item heights and
colors. But I'd like to give ListView a try.
 
Hi,

I was not aware of this limitation in the first place.

255 is VERY big though.
Have you try using other control? like ListView or even a
DataGridView ?

Well, I don't think 255 is really long enough. Maybe for general
purposes, but not in my case. I'll try ListView. DataView is far too
complex. Thank you for your answer, and have a nice day.
 
I don't know why the limit exists.  I admit, I didn't even realize it  
did.  Possibly a legacy thing, from when storing item heights in 8 bits 
was an important memory optimization.

You may want to reconsider the value of having items larger than 255  
pixels in a ListBox.  That's a lot of screen real-estate for something  
being presented as a single item in a larger list.  But, if you insist, 
you might look at the ListView class instead.  It has similar  
functionality, but is visually the more robust of the two classes (ListBox  
is more data-oriented) and so might support larger items.

Pete

The List mode of ListView does not seem to support setting individual
item lengths at all...
 
The List mode of ListView does not seem to support setting individual
item lengths at all...

The List mode of a list view is quite different from the way a standard list
box works. The Detail mode is much closer.
 
Back
Top