Recent

Author Topic: Colunns with richmemo?  (Read 14224 times)

Fabius

  • Jr. Member
  • **
  • Posts: 59
Colunns with richmemo?
« on: June 22, 2021, 06:54:16 pm »
       RichMemo1.TabOrder := 4;

       RichMemo1.??

Good morning all
how do you make colunn  with richmemo?

I do not find

Thank you in advance for a possible response
« Last Edit: June 28, 2021, 08:09:38 am by Fabius »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: paragraphs with richmemo?
« Reply #1 on: June 22, 2021, 07:03:33 pm »
how do you make paragraphs with richmemo?
just add some text with a line-break in it.
a line break ends the current paragraph and starts a new one

If you need to change paragraph layout, then you should be using SetParaMetric method

Fabius

  • Jr. Member
  • **
  • Posts: 59
Re: paragraphs with richmemo?
« Reply #2 on: June 23, 2021, 10:21:07 am »
Hello, thanks for the reply, but it doesn't seem to suit me

on the video, what i want to do colunns

i am wondering if i can do this with richedit from lazarus?


https://www.youtube.com/watch?v=3PF2RNcd5E8
« Last Edit: June 23, 2021, 10:31:07 am by Fabius »

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: paragraphs with richmemo?
« Reply #3 on: June 25, 2021, 02:15:33 am »
On the video there are no columns, there are tabs.
But RichMemo does support tabs as well.

Fabius

  • Jr. Member
  • **
  • Posts: 59
Re: paragraphs with richmemo?
« Reply #4 on: June 25, 2021, 11:58:01 am »
Hello, thank you for the answer, I had seen this page, but I did not understand correctly
I don't understand how to make a tab
I can't find a good example with the correct spelling

you would have an example, please  :)

vladimirr

  • New Member
  • *
  • Posts: 29
Re: paragraphs with richmemo?
« Reply #5 on: June 26, 2021, 09:57:49 am »
Quote
I don't understand how to make a tab

You have to use '\tab ' inside your rich string.

example := 'some text \tab moretext';

Fabius

  • Jr. Member
  • **
  • Posts: 59
Re: paragraphs with richmemo?
« Reply #6 on: June 28, 2021, 08:08:57 am »
Hello
I have trouble understanding, sorry

my end of the program
I list the records of the table

I would like each field of the row to be in columns

How to do ?

thank you in advance


 while not lignesDeSaisie.EOF do
          begin
           NnnnLignes := NnnnLignes+1;

           Lllll := '| ' + lignesDeSaisie.FieldByName('compte').AsString + ' \tab ' + lignesDeSaisie.FieldByName('label').AsString + ' \tab ' + FloatToStr(lignesDeSaisie.FieldByName('credit').AsFloat) + ' #9  | ' + FloatToStr(lignesDeSaisie.FieldByName('debit').AsFloat) + ' |';

            ////RichMemo1.Lines.Add('|----------------------------------------------------------------------');

            RichMemo1.Lines.Add(Lllll);




            lignesDeSaisie.Next;
          end;                       

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Colunns with richmemo?
« Reply #7 on: June 28, 2021, 07:41:48 pm »
here's the code sample:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   st : TTabStopList;
  4.   i  : integer;
  5. begin
  6.  
  7.   RichMemo1.GetParaTabs(0, st); // getting the current tabs
  8.   st.Count:=8;
  9.   SetLength(st.Tabs, st.Count);
  10.   for i:=0 to length(st.Tabs)-1 do
  11.     st.Tabs[i].Offset:=i*72;
  12.   RichMemo1.SetParaTabs(-1,-1,st); // assigning tabs stops
  13.  
  14.   // assigning text with tabs (#9)
  15.   RichMemo1.Lines.Add('hello'#9'world'#9'to'#9'columns');
  16.   RichMemo1.Lines.Add('does'#9'it'#9'look'#9'good'#9'?');
  17.   RichMemo1.Lines.Add('tab'+#9+'is'+#9+'character'+#9+'9');
  18. end;

upd I've added this sample to the wiki page
« Last Edit: June 28, 2021, 08:24:50 pm by skalogryz »

Fabius

  • Jr. Member
  • **
  • Posts: 59
Re: Colunns with richmemo?
« Reply #8 on: June 29, 2021, 05:58:01 pm »
Hello
big thank you for this constructive response :)

Do you know how to adjust the width of each column and what is fixed, is it possible?

I have table fields and the content is variable

Fabius

  • Jr. Member
  • **
  • Posts: 59
Re: Colunns with richmemo?
« Reply #9 on: June 29, 2021, 05:59:33 pm »
My code

begin
(*
*)
RichMemo1.GetParaTabs(0, st); // getting the current tabs
st.Count:=8;
SetLength(st.Tabs, st.Count);
for i:=0 to length(st.Tabs)-1 do
  st.Tabs.Offset:=i*172;  ///plus large
RichMemo1.SetParaTabs(-1,-1,st); // assigning tabs stops

// assigning text with tabs (#9)
RichMemo1.Lines.Add('Compte'#9'Label..................................'#9'Credit'#9'Debit');
  while not lignesDeSaisie.EOF do
  begin
   NnnnLignes := NnnnLignes+1;

   Lllll := lignesDeSaisie.FieldByName('compte').AsString + #9 + lignesDeSaisie.FieldByName('label').AsString + #9 + FloatToStr(lignesDeSaisie.FieldByName('credit').AsFloat) + #9 + FloatToStr(lignesDeSaisie.FieldByName('debit').AsFloat) ;

    ////RichMemo1.Lines.Add('|----------------------------------------------------------------------');

    RichMemo1.Lines.Add(Lllll);



    lignesDeSaisie.Next;
  end;
end;

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Colunns with richmemo?
« Reply #10 on: June 29, 2021, 06:47:07 pm »
you can set the width of every "column" when you're populating Tabs array TTabStopList structure.
Just keep in mind that every column is an offset from the left-most side of the control. Thus is should always be greater than the previous column
Here's an example:
Code: Pascal  [Select][+][-]
  1. st.Count:=4;
  2. SetLength(st.Tabs, st.Count);
  3. st.Tabs[0]:=64;
  4. st.Tabs[1].Offset:=st.Tabs[0].Offset + 32;
  5. st.Tabs[2].Offset:=st.Tabs[1].Offset + 128;
  6. st.Tabs[3].Offset:=st.Tabs[2].Offset + 64;
  7. RichMemo1.SetParaTabs(-1,-1,st);
  8.  
If you're working in Windows or macOS or using Qt5 for linux, you might be able to use tab Alignment as well to make the values "right-aligned" which is usually used for money.
Code: Pascal  [Select][+][-]
  1. st.Tabs[1].Align:=tabRight;
  2.  
(which seems to be applicable for you in case of credit and debit columns)
« Last Edit: June 29, 2021, 06:50:11 pm by skalogryz »

AL

  • Sr. Member
  • ****
  • Posts: 256
Re: Colunns with richmemo?
« Reply #11 on: June 29, 2021, 07:42:19 pm »
You might consider using a StringGrid for this.
https://wiki.freepascal.org/TStringGrid
Laz 3.1, fpc 3.2.2, Win10
Laz 3.1  fpc 3.2.2, MacOS Monterey running on VMWare/Win 10
Laz 3.1  fpc 3.2.2 Ubuntu 20.04

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Colunns with richmemo?
« Reply #12 on: June 30, 2021, 07:25:05 am »
As said, it sounds like you should try a TStringGrid.

It is the difference between creating columns in a word processor versus in a spreadsheet.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

Handoko

  • Hero Member
  • *****
  • Posts: 5122
  • My goal: build my own game engine using Lazarus
Re: Colunns with richmemo?
« Reply #13 on: June 30, 2021, 07:57:45 am »
As said, it sounds like you should try a TStringGrid.
+1

TS should use TStringGrid or TDBGrid.

Here has searchable stringgrid demos showing how to load data from TDbf, display them to a TStringGrid and do searching with color highlight:
https://wiki.freepascal.org/Portal:HowTo_Demos#User_Interface
« Last Edit: June 30, 2021, 08:07:48 am by Handoko »

Fabius

  • Jr. Member
  • **
  • Posts: 59
Re: Colunns with richmemo?
« Reply #14 on: June 30, 2021, 11:15:30 am »
Skalogryz

Thank you  :)

 

TinyPortal © 2005-2018