Jump to content
Sign in to follow this  
robertjohns

ListView Items additions

Recommended Posts

I need to add Listview items from 2 Memo's , I am using Delphi 10.2 Tokyo

 

Memo1 lines are as

line1

line2

line3

line4

line5

 

Memo2 lines are as

something1

something2

something3

something4

something5

 

Need to add these 2 Memo lines into Listview

 

Listview Caption = Memo1 lines

Listview SubItem = Memo2 lines

 

Need help to achieve this

 

Thanks in advance

 

 

Share this post


Link to post
33 minutes ago, robertjohns said:

Need to add these 2 Memo lines into Listview

 

Listview Caption = Memo1 lines

Listview SubItem = Memo2 lines

Be sure View is report 

 

Here's 11.1 vintage clues on a project I am working on Allistair has a video on strUtils that showed similar stuff. 

procedure TForm3.Button3Click(Sender: TObject);
var
  tvCol: TListColumn;
  Vi: TListView;
  li: TListItem;
begin
  var
  SL := TStringList.Create;
  var
  ctL := TStringList.Create;
  SL.LoadFromFile('Logger11.csv');
  LV.Clear;
  for var R := 0 to SL.Count - 1 do
  begin
    ctL.CommaText := SL.Strings[R];

    if R = 0 then
      for var K := 0 to ctL.Count - 1 do
      begin
        tvCol := LV.Columns.add;
        tvCol.Caption := ctL[K];
        tvCol.Width := 120;
      end

    else
      begin
        li := LV.items.add;
        li.Caption := ctL[0];
        ctL.Delete(0);
        li.SubItems.CommaText := (ctL.CommaText);
      end;
  end;
  SL.Free;
  ctL.Free;

end;

 

Share this post


Link to post
25 minutes ago, Pat Foley said:

Be sure View is report 

 

Here's 11.1 vintage clues on a project I am working on Allistair has a video on strUtils that showed similar stuff. 


procedure TForm3.Button3Click(Sender: TObject);
var
  tvCol: TListColumn;
  Vi: TListView;
  li: TListItem;
begin
  var
  SL := TStringList.Create;
  var
  ctL := TStringList.Create;
  SL.LoadFromFile('Logger11.csv');
  LV.Clear;
  for var R := 0 to SL.Count - 1 do
  begin
    ctL.CommaText := SL.Strings[R];

    if R = 0 then
      for var K := 0 to ctL.Count - 1 do
      begin
        tvCol := LV.Columns.add;
        tvCol.Caption := ctL[K];
        tvCol.Width := 120;
      end

    else
      begin
        li := LV.items.add;
        li.Caption := ctL[0];
        ctL.Delete(0);
        li.SubItems.CommaText := (ctL.CommaText);
      end;
  end;
  SL.Free;
  ctL.Free;

end;

 

 

Thanks for reply

 



Need to add these 2 Memo lines into Listview

 

Listview Caption = Memo1 lines

Listview SubItem = Memo2 lines

 

SL.LoadFromFile('Logger11.csv');

 

but the I am seeking help about using Memo1 lines as Listview Caption and Memo2 lines as Listview subitem

Edited by robertjohns

Share this post


Link to post

The clues did not include that Memo1.Lines  equates  to crL: StringList  using ctL[0] for caption.  The ctL.commatext is used for the subitems. 

again viewstyle is vsReport set with F11 object injector.  

  

Share this post


Link to post
7 hours ago, Pat Foley said:

The clues did not include that Memo1.Lines  equates  to crL: StringList  using ctL[0] for caption.  The ctL.commatext is used for the subitems. 

again viewstyle is vsReport set with F11 object injector.  

  

Thanks again for your reply . loading from file it is easy but I need it from 2 memo lines and it seems harder to achieve it especially for me

May some will come out with solution and help me here

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×