Solved

How to edit the subitems of a list view

Posted on 2004-10-08
15
348 Views
Last Modified: 2012-05-05
... in report style.
0
Comment
Question by:__alex
[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
  • 8
  • 3
  • 3
  • +1
15 Comments
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 12258036
procedure TForm1.FormCreate(Sender: TObject);
var
  item    : TListItem;
begin
  // add one item
  item := TListItem.Create(ListView1.Items);
  item := ListView1.Items.Add;
  item.Caption := 'Column 1';
  item.SubItems.Add('Column 2');
  item.SubItems.Add('Column 3');
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  lc_item    : TListItem;
begin
  // modify it
  lc_item := ListView1.Items[0];
  lc_item.SubItems[0] := 'Change second column';
end;
0
 
LVL 2

Accepted Solution

by:
gary_williams earned 250 total points
ID: 12258039
By "edit" do you mean "modify programmatically" or "allow the user to modify via typing into a cell"?

If the former case, simply get a pointer to the TListItem you want to change (either ListView.Selected or ListView.Items[RowNumber]), then add, insert, delete, or modify an element in its TStrings property named "SubItems".

The latter case is not possible with TListView.  You might consider using a TStringGrid instead.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12258234
procedure TFormMain.Button1Click(Sender: TObject);
begin
  ListView1.Items[1].SubItems[0] := 'Kylie Minogue';
end;
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Expert Comment

by:esoftbg
ID: 12258242
The above change the first Subitem of the second Item
0
 
LVL 2

Author Comment

by:__alex
ID: 12258322
> By "edit" do you mean "modify programmatically" or "allow the user to modify via typing into a cell"?
Mea culpa! I meant the counterpart to TListItem.EditCaption (= typing into cell).
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12258546
Why don't use a StringGrid ?
0
 
LVL 2

Author Comment

by:__alex
ID: 12258898
Well, I'll head for the string grid thingy, thanks!
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12260305
> "How to edit the subitems of a list view"
Just a little note:   If the question was
   "How to edit the subitems of a list view AT DESIGN TIME"  it wold be more clear

thanks ....
0
 
LVL 2

Expert Comment

by:gary_williams
ID: 12261506
But he's not talking about design time.  He's talking about at runtime.  (notice the TListItem.EditCaption comment four comments up from this one.)
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12266443
I so sorry again, but at runtime works only for Items:
  ListView1.Items[1].EditCaption;
but not for subitems:
  ListView1.Items[1].SubItems[0].EditCaption;  // so EditCaption method is not for subitems
May be I am wrong, if so excuse me, but the question is: "How to edit the subitems of a list view", "... in report style."

0
 
LVL 2

Expert Comment

by:gary_williams
ID: 12267434
Yes, you are correct.  Were you implying that I was implying that EditCaption worked for SubItems?  I only mentioned the EditCaption comment above as evidence that the person posing the question was interested in a run-time solution, not a design-time solution.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12268361
O.k. who asks the question desides which comment is useful ....
0
 
LVL 2

Author Comment

by:__alex
ID: 12274426
How I like flame wars...

I never talked about design time.
gary_williams told me:
  - that it's not possible to edit the subitems of a listview via GUI
  - to use a TStringGrid instead
Even though my question was not very accurate he gave me the neccessary hints.
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12274485
 __alex,
Excuse me, if it seems like a > flame wars...,
but I am not resent or disappointed,
I just specify:
> O.k. who asks the question desides which comment is useful ....
It is your right to grade the comment you like !
I don't conest anything !
:-))
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 12274490
>I don't conest anything !
I don't contest anything !

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

752 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