Solved

TListView

Posted on 2001-06-20
6
470 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
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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 discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 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

21 Experts available now in Live!

Get 1:1 Help Now