Problem with TlistView.Repaint

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

sbondalapatiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

KarlisBCommented:
can you describe what you mean with " not getting the items displayed properly".
maybe a screen-shot?
0
sbondalapatiAuthor Commented:
after repaint its showing blank listview.
0
Emmanuel PASQUIERFreelance Project ManagerCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Geert GOracle dbaCommented:
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
Geert GOracle dbaCommented:
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
sbondalapatiAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.