Lazarus

Programming => Packages and Libraries => RichMemo => Topic started by: Fabius on June 22, 2021, 06:54:16 pm

Title: Colunns with richmemo?
Post by: Fabius 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
Title: Re: paragraphs with richmemo?
Post by: skalogryz 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
Title: Re: paragraphs with richmemo?
Post by: Fabius 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
Title: Re: paragraphs with richmemo?
Post by: skalogryz on June 25, 2021, 02:15:33 am
On the video there are no columns, there are tabs.
But RichMemo does support tabs (https://wiki.freepascal.org/RichMemo#SetParaTabs) as well.
Title: Re: paragraphs with richmemo?
Post by: Fabius 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  :)
Title: Re: paragraphs with richmemo?
Post by: vladimirr 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';
Title: Re: paragraphs with richmemo?
Post by: Fabius 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;                       
Title: Re: Colunns with richmemo?
Post by: skalogryz 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 (https://wiki.freepascal.org/RichMemo/Samples)
Title: Re: Colunns with richmemo?
Post by: Fabius 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
Title: Re: Colunns with richmemo?
Post by: Fabius 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;
Title: Re: Colunns with richmemo?
Post by: skalogryz 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)
Title: Re: Colunns with richmemo?
Post by: AL on June 29, 2021, 07:42:19 pm
You might consider using a StringGrid for this.
https://wiki.freepascal.org/TStringGrid (https://wiki.freepascal.org/TStringGrid)
Title: Re: Colunns with richmemo?
Post by: VTwin 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.
Title: Re: Colunns with richmemo?
Post by: Handoko 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 (https://wiki.freepascal.org/Portal:HowTo_Demos#User_Interface)
Title: Re: Colunns with richmemo?
Post by: Fabius on June 30, 2021, 11:15:30 am
Skalogryz

Thank you  :)
Title: Re: Colunns with richmemo?
Post by: Fabius on June 30, 2021, 11:21:03 am
I find the memo easier than the stringgrid to print
but maybe I'm wrong :(
TinyPortal © 2005-2018