Solved

other Screen Flickers while adding items to ListBox

Posted on 2001-09-06
5
348 Views
Last Modified: 2010-04-06
the taskbar flickers while my program is adding items to the listbox. I already applied the lockwindowupdate to my program.

how can i stop the flickering?  thanks a lot.
0
Comment
Question by:JPDP
5 Comments
 
LVL 6

Expert Comment

by:DrDelphi
ID: 6463006
Well, if you are adding a lot of things to the list at one time, you might consider adding them to an offscreen TStringlist first, and then assigning that to the listbox. For example:


procedure TForm1.FormCreate(Sender: TObject);
var loopint:integer;
begin
  for loopint:=0 to 1000 do //add 1000 items to the listbox
  begin
    listbox1.Items.add(inttostr(loopint));
  end;
end;


procedure TForm1.Button1Click(Sender: TObject);
var loopint:integer;
    lstItems:TstringList;
begin
  LstItems:=Tstringlist.create;
  LstItems.AddStrings(Listbox1.items);//asign the current items to the stringlist first
  for loopint:=0 to 1000 do
  begin
    lstitems.Add(inttostr(loopint+1000)); //and add 1000 more
  end;
  Listbox1.items:=lstItems;//assign the Stringlist to the listbox ... no flicker!
  LstItems.free;// free resources
  end;



Good luck!!
0
 
LVL 3

Accepted Solution

by:
Stefaan earned 25 total points
ID: 6463255
Hi,

Have you already tried using the BeginUpdate and EndUpdate ?

TheListBox.Items.BeginUpdate;

// now add your items

TheListBox.Items.EndUpdate;

Best regards,


Stefaan
0
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6463303
Stefaan is correct. I would advise *against* using LockWindowUpdate in this case.
0
 
LVL 1

Expert Comment

by:Dennis9
ID: 6463751
Hi.
This will help a lot against flicking, u should just set it in the oncreate of the form:
ListBox1.DoubleBuffered := true;

Dennis
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 6466248
listening
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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