Recent

Author Topic: Numbered list in RichMemo  (Read 4224 times)

paxnet_be

  • New Member
  • *
  • Posts: 14
Re: Numbered list in RichMemo
« Reply #15 on: August 02, 2023, 11:36:45 am »
May be it's useful to know, that on my Linux Lazarus works with GTK2.

rvk

  • Hero Member
  • *****
  • Posts: 6324
Re: Numbered list in RichMemo
« Reply #16 on: August 02, 2023, 11:58:03 am »
I've just tried it in Ubuntu and auto numbering when typing just doesn't work.
I guess this is a limitation of the widget in the OS.

What you can do is first just add all the lines you want (with #13 / new lines separated).
Then apply the numbering to your desired text.

Something like this:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button2Click(Sender: TObject);
  2. var
  3.   pn: TParaNumbering;
  4. begin
  5.   RichMemo1.Clear;
  6.   RichMemo1.Lines.Add('First item');
  7.   RichMemo1.Lines.Add('Second item');
  8.   RichMemo1.Lines.Add('Third item');
  9.  
  10.   pn.Style := pnNumber;
  11.   pn.Indent := 14;
  12.   pn.NumberStart := 1;
  13.   pn.SepChar := SepDot;
  14.   RichMemo1.SetParaNumbering(0, Length(RichMemo1.Lines.Text) - 1, pn);  // -1 so the last line doesn't get a number
  15.  
  16. end;

BTW. There is a unit RichMemoHelpers which has some extra helper functions.
When adding the RichMemoHelpers to your uses you can directly access SelAttributes without needing to fiddle with a separate record.

Code: Pascal  [Select][+][-]
  1. uses RichMemoHelpers;
  2. //...
  3.   RichMemo1.SelAttributes.Color:= clBlue;
  4.   RichMemo1.SelAttributes.Style := RichMemo1.SelAttributes.Style + [fsBold, fsItalic];

Unfortunately there is no such helper for the ParaNumbering.
But it does for TParaMetric in Paragraph.

paxnet_be

  • New Member
  • *
  • Posts: 14
Re: Numbered list in RichMemo
« Reply #17 on: August 02, 2023, 12:34:10 pm »
This solution works for me !  :D

I will use this further in my application.

Thank you very much, rvk, for your support.

 

TinyPortal © 2005-2018