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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T02:07:31+00:00 2026-05-13T02:07:31+00:00

in a label i can add a new line like this Label.Caption:=’First line’+#13#10+’SecondLine’; can

  • 0

in a label i can add a new line like this

Label.Caption:='First line'+#13#10+'SecondLine';

can this be done in a TListView?

listItem:=listView.Items.Add;
listItem.Caption:='First line'+#13#10+'SecondLine';

thanks

  • 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-13T02:07:32+00:00Added an answer on May 13, 2026 at 2:07 am

    It is possible to have multiline strings in a standard TListView in vsReport style, but AFAIK it doesn’t support varying row heights. However, if you have all rows with the same number of lines > 1 you can achieve that quite easily.

    You need to set the list view to OwnerDraw mode, first so you can actually draw the multiline captions, and second to get a chance to increase the row height to the necessary value. This is done by handling the WM_MEASUREITEM message, which is sent only for owner-drawn list views.

    A small example to demonstrate this:

    type
      TForm1 = class(TForm)
        ListView1: TListView;
        procedure FormCreate(Sender: TObject);
        procedure ListView1DrawItem(Sender: TCustomListView; Item: TListItem;
          Rect: TRect; State: TOwnerDrawState);
      private
        procedure WMMeasureItem(var AMsg: TWMMeasureItem); message WM_MEASUREITEM;
      end;
    
    { TForm1 }
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      ListView1.ViewStyle := vsReport;
      ListView1.OwnerDraw := True;
      ListView1.OwnerData := True;
      ListView1.Items.Count := 1000;
      with ListView1.Columns.Add do begin
        Caption := 'Multiline string test';
        Width := 400;
      end;
      ListView1.OnDrawItem := ListView1DrawItem;
    end;
    
    procedure TForm1.ListView1DrawItem(Sender: TCustomListView;
      Item: TListItem; Rect: TRect; State: TOwnerDrawState);
    begin
      if odSelected in State then begin
        Sender.Canvas.Brush.Color := clHighlight;
        Sender.Canvas.Font.Color := clHighlightText;
      end;
      Sender.Canvas.FillRect(Rect);
      InflateRect(Rect, -2, -2);
      DrawText(Sender.Canvas.Handle,
        PChar(Format('Multiline string for'#13#10'Item %d', [Item.Index])),
        -1, Rect, DT_LEFT);
    end;
    
    procedure TForm1.WMMeasureItem(var AMsg: TWMMeasureItem);
    begin
      inherited;
      if AMsg.IDCtl = ListView1.Handle then
        AMsg.MeasureItemStruct^.itemHeight := 4 + 2 * ListView1.Canvas.TextHeight('Wg');
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a new line in this. This is my sample code:
How can I add a newline to a plot's label (e.g. xlabel or ylabel)
I was wondering how I can add \label into bibtex so that when I
How can I add two label in the same grid box? e.g. in row
Can I set label visibility in Flex ? newUser = new LinkButton(); newUser.label =
I want to add a new LabelField(String label, long style) but if I use
I'm a new to Flex, and I'm trying to add a second label to
How can I add a newline in the text of a label in WPF
How can I add an additional icon to the Name/Lable of app, just the
I have a GridView with a Label. The value of the Label can be

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.