As the title says.
History: To reduce flicker in my ListBox with DrawMode.OwnerDrawFixed
and a custom OnDrawItem() I used the subclassing example from this page: http://yacsharpblog.blogspot.no/2008/07/listbox-flicker.html
which uses
SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
It works well except for one thing: When I scroll sideways to see long strings the OnDrawItem() does not seem to understand that it should draw with an offset. It seems like the horizontal scroll offset is lost somewhere on the way and the area OnPaint() has been called to fill in gets filled in by my OnDrawItem() as if the ListBox was not scrolled sideways at all.
Please note: If I disable ControlStyles.UserPaint
and let the system call OnDrawItem() directly, it works fine and I can scroll side-ways normally. But it flickers and is too slow to be useful. I need the custom OnPaint() and the ControlStyles.OptimizedDoubleBuffer
to make it smooth.
Can someone tell me where/how to get the horizontal scroll position, or what needs to be done to make this happen automatically, like when the system calls OnDrawItem?