Enabling double buffering for a ListView control?

  • Thread starter Thread starter Robin Tucker
  • Start date Start date
R

Robin Tucker

I wanted to enable double buffering for my list view control to avoid
flicker when adding or removing new records, so I subclassed it. However, I
just plain don't get ANYTHING displayed after enabling double buffering. Is
there more to this functionality than meets the eye?



Public Class ListViewDblBuffer
Inherits ListView

Public Sub EnableDblBuffer()
Me.SetStyle(ControlStyles.DoubleBuffer _
Or ControlStyles.UserPaint _
Or ControlStyles.AllPaintingInWmPaint, _
True)
Me.UpdateStyles()
End Sub
End Class
 
Hi Robin,
I wanted to enable double buffering for my list view control to avoid
flicker when adding or removing new records.

Do you know there are two methods to prevent that?

"Listview1.BeginUpdate()" and "listview1.EndUpdate()"

Maybe that is easier for the problem?

Cor
 
Yes, but I still get flicker with BeginUpdate and EndUpdate in use. I'm
thinking that because it isn't double buffered, its going to "blank" the
window before rendering regardless. I double buffered my ListBox items
(custom drawn) manually before I saw that double bufferring was an option in
there and windows forms can do it for you - but I can't seem to get it to
work!
 
Hi Robin,

As you hadn't mentioned it, I was going to suggest Begin and End Update,
but Cor beat me to it! :-)

I notice that you are using the UserPaint style. The documentation for it
says
The control paints itself rather than the operating system doing so.

I don't think it was worded very well - 'paints itself' means that <you>
get to paint it! Do you have your own painting code for the ListView as well?

On the other hand, if you are custom drawing your ListItems, shouldn't
<they> be the ones which you subclass so that you can give them
ControlStyles.DoubleBuffer?

This isn't from experience. I'm only throwing ideas out here, and may be
well off the mark.

Regards,
Fergus
 
You are right, what an idjeet I am. I don't want to owner draw it, just
have it double buffered.

Nice one - its fine now.
 
Back
Top