Solved

TListView

Posted on 2001-06-20
6
478 Views
Last Modified: 2010-04-06
How do I add items (text) in a Tlistview object?
sample code please!
thanx
0
Comment
Question by:gikam
[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
6 Comments
 
LVL 5

Accepted Solution

by:
TheNeil earned 30 total points
ID: 6210145
Like this:

procedure TfrmMissionMain.Button1Click(Sender: TObject);
VAR
  NewItem : TListItem;
begin
  NewItem := ListView1.Items.Add;
  NewItem.Caption := 'Some text';
end;

The Neil =:)
0
 
LVL 2

Author Comment

by:gikam
ID: 6210180
how do I select the column where the item will be added?
0
 
LVL 3

Expert Comment

by:nnbbb09
ID: 6210220

If you are using the listview in report mode then the Caption property of a TListItem corresponds to the first column in the listview. To add text to other columns you need to add strings to the subitems property which is of type TStrings. eg :

VAR
 NewItem : TListItem;
begin
 NewItem := ListView1.Items.Add;
 NewItem.Caption := 'Some text'; // this is the first column

 NewItem.SubItems.Add('Text 2'); // this is the second column

 NewItem.SubItems.Add('Text 3'); // this is the second column

  // and so on...

end;

regards

Jo
0
 
LVL 1

Expert Comment

by:alx512
ID: 6255346
procedure TfrmMissionMain.Button1Click(Sender: TObject);
VAR
 NewItem : TListItem;
begin
 NewItem := ListView1.Items.Add;
 NewItem.Caption := 'Some text';

 ListView1.Selected := NewItem;
 ListView1.Focused  := NewItem;
end;
0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 8685004
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Accept TheNeil's comment as answer

I would have recommended a split, but the points are not high enough to warrant that, and TheNeil answered the original question first.

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Thank you,
Russell

EE Cleanup Volunteer
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

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 use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

710 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