Click here to Skip to main content
15,885,216 members
Articles / Programming Languages / Visual Basic
Tip/Trick

Double Buffered List View

Rate me:
Please Sign up or sign in to vote.
5.00/5 (5 votes)
17 Jan 2014CPOL 19K   4   1
Double Buffer a List View Control to eliminate all flickering associated with it.

Introduction

There's a simple way to double buffer a list view control to eliminate any flickering when adding data or images to the List View.

Background

List View Control

Using the Code

When using a List View, set your main form to double buffered and create a new class called ListViewDoubleBuffered. In this class, you'll set your inherited List View to be Double Buffered. You can't set Double Buffering on the List View control when dragging and dropping the control to the form. You have to program the control yourself in code then add it to your form.

The code for your new class should look like this:

VB.NET
Public Class ListViewDoubleBuffered
    Inherits ListView

    Public Sub New()
        Me.DoubleBuffered = True
    End Sub
End Class 

That's all there is to it. All you have to do now is create the List View using the class above and add it to the form.

VB.NET
Private lvListViewDoubleBuffered as New ListViewDoubleBuffered

lvListViewDoubleBuffered = New ListViewDoubleBuffered

With lvListViewDoubleBuffered
     'add any properties here
End With

Me.Controls.Add(lvListViewDoubleBuffered) 

I added over 1,200 file names to the List View in Details View and added over 3,000 images to the List View in LargeIcon View without any flickering.

Points of Interest

Flicker Free List View Control

History

  • v1.0.0.2

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Junior)
United States United States
I'm a hobbyist programmer in VB, C# and Java. I have an associate's degree in Computer Sciences.

Comments and Discussions

 
QuestionThank you very much :-) Pin
Member 342168315-Nov-22 4:57
Member 342168315-Nov-22 4:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.