Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

STOPPING Automatic VISUAL UPDATE of ListBox by Windows?

Posted on 1998-11-26
2
Medium Priority
?
148 Views
Last Modified: 2010-05-03
Is there a way to stop that visual update that windows does to a listbox control when ie. you set an item in the box to be checked with a listbox1.Selected(0) = true? Everytime i call the select function to have an item selected it ALWAYS shows it checking onscreen. This is completely fine, however, when i have to select 2000 items that reside in the box seeing each one checked on takes MUCH LONGER than if it were to do it in the background (non-visible) and then have it display the final list all checked in one update.
I am sure most of you will say "just have another ListBox with the same content, make it invisible, and have all the items checked on and once it is done just set the original to invisble and the new to visible". I can do this but i don't want to be so wasteful with memory. Is there a function in vb to tell a control to not have its visually changed contents displayed until i want it to?

Thanks
0
Comment
Question by:aniston
[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
2 Comments
 
LVL 14

Accepted Solution

by:
waty earned 40 total points
ID: 1446882
Use the following function :

Private Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long


Public Sub SetRedraw(frm As Form, bRedraw As Boolean)
   ' #VBIDEUtils#************************************************************
   ' * Programmer Name  : Waty Thierry
   ' * Web Site         : www.geocities.com/ResearchTriangle/6311/
   ' * E-Mail           : waty.thierry@usa.net
   ' * Date             : 19/11/98
   ' * Time             : 16:43
   ' * Module Name      : Lib_Module
   ' * Module Filename  : Lib.bas
   ' * Procedure Name   : SetRedraw
   ' * Parameters       :
   ' *                    frm As Form
   ' *                    bRedraw As Boolean
   ' **********************************************************************
   ' * Comments         : Enabled/Disable Window redraw
   ' *
   ' *
   ' **********************************************************************

   If (bRedraw = True) Then
      LockWindowUpdate 0
      frm.Refresh
   Else
      LockWindowUpdate frm.hwnd
   End If

End Sub

0
 

Author Comment

by:aniston
ID: 1446883
You are a ****ing lifesaver!! Thanks very much for such a BRILLIANT ANSWER
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

721 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