Click here to Skip to main content
15,868,006 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm a Delphi Dabbler Using Delphi XE8 and a TListView
This has probably been asked before but none of the answers I've seen helped.
I have a list of websites. 2 columns.

i.e
SHORTNAME URL
SLACK     www.slack.com
ZOOM      www.zoom.com

etc.

I want to display only the first column with the short name of the website.
The user selects the website(s) he/she wants and a procedure runs and selects only those
that have been CHECKED and adds the actual URL and ONLY the URL to a memo box.

Currently trying this with a TListView which is looking overly complicated in relation to a TListBox. I've tried something along these lines but I get the first CHECKED URL and then it bombs out. Surely it should be as simple as this...

for i := 0 to ListViewURL.Items.Count - 1 do
     begin
       if ListViewURL.Items[i].Checked = True then
        begin
          // Add only the URL to the memo
          Memo1.Lines.Add(ListViewURL.Items[i].SubItems[i]);
        end
       else
     end;


Can anyone suggest a solution or is there another way to get the result I want.

Thank you in advance

What I have tried:

Currently trying this with a TListView which is looking overly complicated in relation to a TListBox. I've tried something along these lines but I get the first CHECKED URL and then it bombs out. Surely it should be as simple as this...

for i := 0 to ListViewURL.Items.Count - 1 do
     begin
       if ListViewURL.Items[i].Checked = True then
        begin
          // Add only the URL to the memo
          Memo1.Lines.Add(ListViewURL.Items[i].SubItems[i]);
        end
       else
     end;
Posted
Updated 15-Mar-22 10:32am
v3

1 solution

I think you've overcomplicated this...

If you want to add only url address from currently selected item, use something like this:

Delphi
var
  ci : Integer;
//later
ci := ListViewURL.ItemIndex;
Memo1.Lines.Add(ListViewURL.Items[ci].SubItems[1].Text);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900