Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8252971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:42:46+00:00 2026-06-08T00:42:46+00:00

Right now I am using the following code to get a ListView items value

  • 0

Right now I am using the following code to get a ListView items value and I was wanting to know if this was the proper way to do this or should I be doing it another way.

Example for the parent item value:

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(ListView1.Selected.Caption);
end;

Example for a sub item value:

procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(ListView1.Selected.SubItems.Strings[items_index_here]);
end;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:42:47+00:00Added an answer on June 8, 2026 at 12:42 am

    Your first code seems fine, except you should be checking to see if there is a Selected item first:

    if Assigned(ListView1.Selected) then  // or ListView1.Selected <> nil
      ShowMessage(ListView1.Selected.Caption);
    

    Your second can be simplified (and should include the same check I mentioned above):

    if Assigned(ListView1.Selected) then
      ShowMessage(ListView1.Selected.SubItems[Index]);
    

    TStrings descendants (like TStringList and TListItem.SubItems) have default properties, which is a shortcut to using TStrings.Strings[Index]; you can instead just use TStrings[Index]. Instead of MyStringList.Strings[0], you can just use MyStringList[0], and this applies to things like TMemo.Lines and TListItem.SubItems as well. You don’t need SubItems.Strings[Index], but can just use SubItems[Index].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I'm using the following: export CFLAGS=-O2-isysroot/Developer/SDKs/MacOSX10.5.sdk -arch i386 -I/sw/include/ export LDFLAGS=-Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk,-L/sw/lib/ sudo
Right now I am using this on my string substr($row->review[$i] , 0, 120) but
Using the following code: # List all servers $servers = Get-QADComputer -OSName *server*,*hyper-v* #
I am using following code to get the available disk space of the startup
Ok so i am using the following jquery dropdown menu. I found this code
i am using the following code to get the current time.. NSDate *myDate =
Using the following code, I get a INDEX_SIZE_ERR: DOM Exception 1 error on the
Using Wordpress menu builder, I get the following code: //Pseaudo code <ul id=main-menu-main> <li
I'm trying to execute a command using the following code snippet: foreach($package in (Get-Childitem
We are using a Java EE application and we are right now using Informix

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.