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 6973613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:07:50+00:00 2026-05-27T17:07:50+00:00

My code is the below, it’s working correctly but, but after compiling program i

  • 0

My code is the below, it’s working correctly but, but after compiling program i see all the fullname and country listed vertically something like :

_________________________________
Fullname1
Country1
Fullname2
Country2
Fullname3
Country3
etc…

SQLQuery1.SQL.Text := 'SELECT * FROM users where user_age="'+age+'"';
SQLQuery1.Open;
rec := SQLQuery1.RecordCount;

SQLQuery1.First; // move to the first record
ListView1.Visible := false;
if rec>0 then
begin
while(not SQLQuery1.EOF)do begin
ListView1.Visible := true;
        // do something with the current item
ListView1.AddItem('Full name: '+SQLQuery1['fullname'], Self);
ListView1.AddItem('Country: '+SQLQuery1['cntry'], Self);

    // move to the next record

SQLQuery1.Next;

end;

But i want something Like :

enter image description here

  • 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-05-27T17:07:51+00:00Added an answer on May 27, 2026 at 5:07 pm

    First: add the column headers:

    var
      Col: TListColumn;
    begin
      Col := ListView1.Columns.Add;
      Col.Caption := 'Name';
      Col.Alignment := taLeftJustify;
      Col.Width := 140;
    
      Col := ListView1.Columns.Add;
      Col.Caption := 'Country';
      Col.Alignment := taLeftJustify;
      Col.Width := 140;
    end;
    

    then add the records as follows:

    var
      Itm: TListItem;
    begin
        // start of your query loop
        Itm := ListView1.Items.Add;
        Itm.Caption := SQLQuery1['fullname'];
        Itm.SubItems.Add(SQLQuery1['cntry']);
        // end of your query loop
    end;
    

    Update:

    Of course, in order to get the list as in your screenshot, you need to set the ListView’s ViewStyle property to vsReport

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

Sidebar

Related Questions

code below working fine but not in IE6, IE7, below is the code is
Code below does not run correctly and throws InvalidOperationExcepiton . public void Foo() {
Code below is not working as expected to detect if it is in design
Code below is working well as long as I have class ClassSameAssembly in same
The code below works. But if I comment out the line Dim objRequest As
Code below: $_SESSION = array(); Will it clear all session data? If I wouldn't
The code below shows a line in different colors, but that's a lot of
The code below works, but I suspect there is be a cleaner. Any alternative
My code below kinda works, it creates the User object and saves but it
See code below, for some reason it only works when I put a breakpoint

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.