Columns / Tables

ScaleRichView support and discussion (TRichView add-on for WYSIWYG editing)
Post Reply
pgkammath
Posts: 36
Joined: Fri Nov 24, 2017 6:16 am

Columns / Tables

Post by pgkammath »

Hi,
I want to display some data of variable length in scalerichview as given in the attachment. The Data is taken from a stringgrid. and load to scalerichview by a for ..loop

Can you please guide?
Thanks in advance

Regards
Attachments
Untitled.jpg
Untitled.jpg (47.31 KiB) Viewed 53996 times
Sergey Tkachenko
Site Admin
Posts: 17553
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Columns / Tables

Post by Sergey Tkachenko »

It looks like a table.
Do you want a code showing how to add a table?
pgkammath
Posts: 36
Joined: Fri Nov 24, 2017 6:16 am

Re: Columns / Tables

Post by pgkammath »

Yes , it is like a table. An example code will be greatly appreciated. Also, it would be usel if the example can show how to set the width of a column.

I tried the following code from an example of spreadsheet, but the table is not displayed. But when i did this in the spread sheet example by inserting the Scalerichview instead of the richviewedit, it works there.

CareTable := TRVTableItemInfo.CreateEx(10, 6, FinalData.RichViewEdit.RVData);

CareTable.BorderWidth := 1;
CareTable.CellBorderWidth := 1;
CareTable.CellBorderStyle := rvtbLowered;
CareTable.CellBorderColor := clBtnFace;
CareTable.BorderStyle := rvtbLowered;

for rows := 0 to CareTable.Rows.Count - 1 do begin
for cols := 0 to CareTable.Rows[rows].Count - 1 do
CareTable.Cells[rows, cols].Clear;
end;

CareTable.Cells[0, 0].AddNL('Date & Time', 1, 1);
CareTable.Cells[0, 1].AddNL('Assessment', 1, 1);
CareTable.Cells[0, 2].AddNL('Nursing Diagnosis', 1, 1);
CareTable.Cells[0, 3].AddNL('Nursing Intervention', 1, 1);
CareTable.Cells[0, 4].AddNL('Evaluation', 1, 1);
CareTable.Cells[0, 5].AddNL('Entered by', 1, 1);

CareTable.Cells[0, 1].BestWidth := -60;

FinalData.RichViewEdit.InsertItem('NursesCareData', CareTable);
FinalData.RichViewEdit.ApplyParaStyle(1);
FinalData.RichViewEdit.Format;



Thanks in advance
Sergey Tkachenko
Site Admin
Posts: 17553
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Columns / Tables

Post by Sergey Tkachenko »

Does this code work?
It looks ok, but:

- if you generate document, and want to add a table to the end, call

Code: Select all

CareTable.ParaNo := 1;
FinalData.RichViewEdit.AddItem('NursesCareData', CareTable);
FinalData.RichViewEdit.Format;
- if you want to insert the table in the caret position, as an editing operation, call

Code: Select all

FinalData.RichViewEdit.InsertItem('NursesCareData', CareTable);
FinalData.RichViewEdit.ApplyParaStyle(1); 
or, better (to allow undoing in a single step):

Code: Select all

FinalData.RichViewEdit.TopLevelEditor.BeginUndoGroup(rvutInsert);
FinalData.RichViewEdit.TopLevelEditor.SetUndoGroupMode(True);
FinalData.RichViewEdit.AddItem('NursesCareData', CareTable);
FinalData.RichViewEdit.Format;
FinalData.RichViewEdit.TopLevelEditor.SetUndoGroupMode(False);
pgkammath
Posts: 36
Joined: Fri Nov 24, 2017 6:16 am

Re: Columns / Tables

Post by pgkammath »

Thank you very very much for the prompt solution. Saved me. Just want I wanted.

Regards,
Post Reply