Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TListView

Posted on 2001-06-20
6
Medium Priority
?
481 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 120 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

722 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