listview scrollbar range not correct

G

Guest

I implemented a double buffered listview to eliminate flicker. I set the
following styles, then overrode OnPaint and did the drawing. Everything looks
great! However, if I change the font from default, the column headers are not
drawn with the new font and worse yet the scrollbar doesn't know that font
height has changed and I can never scroll to see the last few items on the
list.

Short of adding my own scrollbar, is there a way to let the column headers
and scrollbar know about the new "range" when the font is changed?


SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint , true);
 
V

VBen

Set DrawMode of the listbox:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwindowsformscomboboxclassdrawmodetopic.asp
You have to override the OnDrawItem AND the OnMeasureItem (or handle the
DrawItem and MeasureItem events) to do the trick. The OnMeasureItem lets you
set the size of each element of the list, so the scrollbar gets sized
correctly:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwindowsformscomboboxclassdrawmodetopic.asp
Hope this helps.
VBen.
 
G

Guest

Thanks so much for your reply. Unfortunately it doesn't look like a ListView
has a DrawMode property or OnDrawItem and OnMeasureItem events. I was hoping
to use a ListView to take advantage of the built in colums and being able to
add subitems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top