listview scrollbar range not correct

  • Thread starter Thread starter Guest
  • Start date Start date
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);
 
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.
 
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.
 
Back
Top