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

x
?
Solved

How to edit the subitems of a list view

Posted on 2004-10-08
15
Medium Priority
?
352 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 1000 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
Technology Partners: 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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…
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

661 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