How to Prevent Flicker when Updating ListView

  • Thread starter Thread starter Charles Law
  • Start date Start date
C

Charles Law

Some of the eagle-eyed amongst you will spot this as a direct follow on from
my earlier post about critical timing in .NET.

I want to use a ListView to display my output (instead of the sluggish
RichTextBox), but it flickers madly when I update it. There have been
numerous posts about this, but I have found no solution. Enabling
double-buffering does not seem to help, so has anyone any idea how it can be
done?

TIA

Charles
 
Charles,

Forget it, I saw listview in the thread however it was not as your problem.

I find it needles to tell to you that there is a standard option for that,
because I assume that you know that and does not work for you as you expect.

Cor
 
Hi David

Thanks for the response. Sadly that does not help, though. I already have it
in place. Every time the EndUpdate method is called the control refreshes,
hence the flicker. I am adding a row every 200 ms, say, and the flicker is
especially bad.

Charles
 
Ok chaps. I have the answer.

It would seem that I had mis-read the purpose of the BeginUpdate/EndUpdate
methods; like many before me I suspect.

These commands actually make the update occur, thus causing the flicker not
reducing it.

I tried all sorts of things, from double-buffering to sub-classing and
filtering the WM_ERASEBKGND message. I even tried LockWindowUpdate from one
of our esteemed number from way back. None of these worked.

The answer is as simple as calling the Update method after adding each item.

<code>
With ListView1
Dim lvi As New ListViewItem("Some really important information")

lvi.ForeColor = Color.Green

.Items.Add(lvi)

.EnsureVisible(.Items.Count - 1)

.Update()
End With
</code>

The result is a silky smooth update, with no flicker. No sub-classing,
filtering, or double-buffering required.

Can you tell I'm happy :-))

Charles
 

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

Back
Top