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

  • Home
  • SEARCH
  • 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 222527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:08:08+00:00 2026-05-11T19:08:08+00:00

When you edit a TLabel’s caption in the form designer, it resizes the TLabel

  • 0

When you edit a TLabel’s caption in the form designer, it resizes the TLabel for you. Is there any way I can get a TMemo to do that, at runtime?

I’d like to be able to take a TMemo, assign something to its .lines.text property, and then tell it to resize itself and not exceed a certain width, though it can get as tall as it wants to. Anyone know how to do that?

  • 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-11T19:08:08+00:00Added an answer on May 11, 2026 at 7:08 pm

    Set the WordWrap property of the TMemo to true, dump your text into it, count the lines, and set the height to the product of the line count and the line height, but you need to know the line height.

    The TMemo does not expose a line height property, but if you’re not changing the font or font size at runtime, you can determine the line height experimentally at design time.

    Here’s the code I used to set the height of the TMemo that had a line height of 13 pixels. I also found that I needed a small constant to account for the TMemo‘s top and bottom borders. I limited the height to 30 lines (396 pixels) to keep it on the form.

    // Memo.WordWrap = True (at design time)
    Memo.Text := <ANY AMOUNT OF TEXT>;
    Memo.Height := Min(19 + Memo.Lines.Count * 13, 396); 
    

    If you absolutely must extract the line height from the object at runtime, then you might use Someone’s answer. Or, you can use TRichEdit, which has the SelAttributes property containing a Height property giving the line height.

    -Al.

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

Sidebar

Related Questions

Edit: For personn interested in a cleaner way to implemenent that, have a look
I want to have CListCtrl.EditLabel() for any column of the list. How can I
Edit: From another question I provided an answer that has links to a lot
EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business
Edit : Solved, there was a trigger with a loop on the table (read
Edit: an important piece might be that I'm calling a cfc method via ajax...
EDIT Leaving this for posterity, but nearly a year later, to get down voted,
I have a DATETIME value some_date that can be null in my database. When
EDIT: More detail here. Basically if you 1. open a tab1 to url1 (GET
I would like to create form based on dynamic parameters that are stored in

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.