Solved

CListCtrl with 1000's of entries is too slow

Posted on 1997-04-03
1
573 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 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