Solved

CListCtrl with 1000's of entries is too slow

Posted on 1997-04-03
1
569 Views
Last Modified: 2013-11-20
I'm using a CListBox to display entries from a large database. My problem is that as the number of entries exceeds a couple of thousand, the time taken to re-draw the ListBox becomes prohibitive. Is there a way of only writing to the Listbox enough entries to fill the screen and then loading new ones from the database as and when the listbox is scrolled. This effect can be seen in the explorer when a directory contains many files. I know that one approach is to use some kind of "virtual listbox" but examples I have seen are very old.
0
Comment
Question by:l.hudson02
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1300819
Before adding entries, you should call CWnd::SetRedraw (CListBox is derived from CWnd).

void CWnd::SetRedraw( BOOL bRedraw = TRUE );
 
Parameters
bRedraw   Specifies the state of the redraw flag. If this parameter is TRUE, the redraw flag is set; if FALSE, the flag is cleared.
Remarks
An application calls SetRedraw to allow changes to be redrawn or to prevent changes from being redrawn.
This member function sets or clears the redraw flag. While the redraw flag is cleared, the contents will not be updated after each change and will not be repainted until the redraw flag is set. For example, an application that needs to add several items to a list box can clear the redraw flag, add the items, and then set the redraw flag. Finally, the application can call the Invalidate or InvalidateRect member function to cause the list box to be repainted.


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to calculate times for developing software? 8 66
repeatSeparator  java  challenge 13 56
Replacement selected text 2 58
tripleUp challenge 7 74
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now