Page 1 of 1
Columns / Tables
Posted: Sun May 17, 2020 6:41 am
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
Re: Columns / Tables
Posted: Sun May 17, 2020 1:02 pm
by Sergey Tkachenko
It looks like a
table.
Do you want a code showing how to add a table?
Re: Columns / Tables
Posted: Mon May 18, 2020 3:49 am
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
Re: Columns / Tables
Posted: Mon May 18, 2020 8:50 am
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);
Re: Columns / Tables
Posted: Mon May 18, 2020 10:10 am
by pgkammath
Thank you very very much for the prompt solution. Saved me. Just want I wanted.
Regards,