Break line in a given character

Asked

Viewed 1,296 times

2

I have an application where a TLabel receives a line from a TMemo,

however the form that I’m exhibiting has to be small, and the information is great.

My idea is that when arriving at a certain number of characters the sentence would continue at the bottom line.

So I’m using the function below to count the number of characters in the first line of the TMemo

tamMemoCaption:=inttostr(Length(form1.memo5.Lines.text));

What I need is that when the size reaches 24 for example the text of TMemo, from there he break to the bass line or a new TLabel receive the information

I tried to use the option WordWrap, but with no results.

Some guidance?

1 answer

3


Imagine and try to use the same internal function that is already using the Length.

procedure CopiaApenasPartesString;
var
  vRestante,
  vTextoAuxiliar : String;  
begin
  vTextoAuxiliar := O texto que você esta inserindo no TMemo;

  if (Length(vTextoAuxiliar) > 24) then
  begin
    Memo.Lines.Add(Copy(vTextoAuxiliar,1,24); //Copia os Primeiros 24 Caracteres
    vRestante := Copy(vTextoAuxiliar,1,Length(vTextoAuxiliar));
    if (Length(vRestante) > 24) then
      Memo.Lines.Add(Copy(vRestante,1,24); //Copia mais 24 Caracteres
  end;
end;

Thus, every 24 characters the text is inserted in the TMemo.

Note that I did not use any repetition structure, you can mount Array as needed or Text size!

But using the very TMemo, defining a Width for it that fits 24 characters and with the property WordWrap activated should already work without any auxiliary code!

  • with small adjustments remained as I needed !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.