Solved

CListCtrl with 1000's of entries is too slow

Posted on 1997-04-03
1
563 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

759 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

19 Experts available now in Live!

Get 1:1 Help Now