?
Solved

Problem with TlistView.Repaint

Posted on 2010-04-07
6
Medium Priority
?
359 Views
Last Modified: 2013-11-23
I used Tlistview Control  and Tlistitem to display items.But i am not getting the items displayed properly.
var
  varListItem: TListItem;

begin
  varListItem         := lvSteps.Items.Add();
  varListItem.Caption := DateTimeToStr(Now);
  varListItem.SubItems.Add(AStepMessage);
  varListItem.ImageIndex := AImageIndex;
  varListItem.MakeVisible(false);
  lvSteps.Repaint();

Open in new window

0
Comment
Question by:sbondalapati
6 Comments
 
LVL 3

Expert Comment

by:KarlisB
ID: 30090989
can you describe what you mean with " not getting the items displayed properly".
maybe a screen-shot?
0
 

Author Comment

by:sbondalapati
ID: 30092497
after repaint its showing blank listview.
0
 
LVL 25

Accepted Solution

by:
epasquier earned 750 total points
ID: 30095974
Repaint is not necessary, the listview will update itself without being told.
If you have a lot of things happening before the application can treat the messages loop (inside your application event that is creating this LV item) it's possible that the actual drawing is delayed until your application return from this event.

If you still have a problem, it's not coming from the little code snippet you provided.

now just a little detail : procedures & functions without parameters do not need the () like in C,C++,Java...
varListItem         := lvSteps.Items.Add;
would work just as well, and is what Pascal/Delphi programmers are used to.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 38

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 750 total points
ID: 30109485
try this:

var
  varListItem: TListItem;
begin
  lvSteps.Items.BeginUpdate;
  try
    varListItem         := lvSteps.Items.Add;
    varListItem.Caption := DateTimeToStr(Now);
    varListItem.SubItems.Add(AStepMessage);
    varListItem.ImageIndex := AImageIndex;
    varListItem.MakeVisible(false);
  finally
    lvSteps.Items.EndUpdate;
  end;
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 30111432
move the MakeVisible line down

var
  varListItem: TListItem;
begin
  lvSteps.Items.BeginUpdate;
  try
    varListItem         := lvSteps.Items.Add;
    varListItem.Caption := DateTimeToStr(Now);
    varListItem.SubItems.Add(AStepMessage);
    varListItem.ImageIndex := AImageIndex;
  finally
    lvSteps.Items.EndUpdate;
  end;
  varListItem.MakeVisible(false);
0
 

Author Closing Comment

by:sbondalapati
ID: 31712163
thanks
0

Featured Post

Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hi, this video explains a free download that you can incorporate into your Access databases, or use stand-alone for contact management. Contacts -- Names, Addresses, Phone Numbers, eMail Addresses, Websites, Lists, Projects, Notes, Attachments…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…
Suggested Courses
Course of the Month5 days, 10 hours left to enroll

589 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