Cannot insert BOLD Text in 1st Row of tables ar runtime

General TRichView support forum. Please post your questions here
Post Reply
alogrep
Posts: 52
Joined: Fri Oct 27, 2006 5:25 pm

Cannot insert BOLD Text in 1st Row of tables ar runtime

Post by alogrep »

Hi Sergey
I hope you can help me with this one.
I create a table in a separate function where richviewedit1 is passed as a var parameter.
Then I fiil the cells like this:
Atable.Cells[0,0].Addnl(lg('Date'),5,-1);
Atable is defined in the pubblic section of Richviewedit1 as
Atable: TRVTableItemInfo;
5 is the Textstyle index of a RvStyle1 wich is used in Richview1.
This style is called 'bold' has size=10 and Style = [fsbold].
(NOTE: I want this style i.e. bold ONLY on the first row, so I use
Atable.Cells[y,x].Addnl(lg('something'),0,-1); on y >0. Also note that if I use 0 instead of -1, the text shows blow the visible cells, i.e. is not visible UNLESS i click on the cell and move the arrow down)

Then inside the RichviewEdit1, in FillFields, I do this (which you suggested to me)
table := TRVTableItemInfo.CreateEx(Atable.Rows.Count,Atable.Rows[0].Count, RichViewEdit1.RVData);
Stream := TMemoryStream.Create;
Atable.SaveToStream(Stream);
Stream.Position := 0;
Atable.free;
table.LoadFromStream(Stream);
Stream.Free;
table.ParaNo := RVData.GetItemPara(i);
RVData.DeleteItems(i, 1);
s := '';
table.Inserting(RVData, s, False);
RVData.Items.InsertObject(i, s, table);
table.Inserted(RVData, i);
if (i>0) and (RVData.GetItemStyle(i-1)=rvsListMarker) then begin
dec(i);
RVData.DeleteItems(i, 1);
end;
When it is displayed, the text inside the cells is NOT bold, and is size 8.
Why?
Thanks for any help
Enrico
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

This is because you add bold text as the second item. Initially, each cell has one empty text item of the 0th style.

Instead of
Atable.Cells[0,0].Addnl(lg('Date'),5,-1);
use
Atable.Cells[0,0].Clear;
Atable.Cells[0,0].Addnl(lg('Date'),5,0);
alogrep
Posts: 52
Joined: Fri Oct 27, 2006 5:25 pm

bold in top rows of table: still does not work

Post by alogrep »

Sorry
It still does not work.
I do check at runtime that style # 5 of RichvieEdiut1 is [fsbold], but when displayed the top cells are not bold.
Am I doing something wrong (or should I do something more) when I load the table from the stream inside the form that contains RichEdit1?
Remember the table is created and loaded in a function in a different unit
(from the one containing RicviewEdit1), like this:
myeditor:=TMyEditor.Create(Self);
try
createAtable(myeditor.reservetable,myeditor.RichViewEdit1)
.....
Thanks again
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

are theeditors where the table is saved and where it is loaded connected to the same rvstyle (or to rvstyles with the same set of styles)? It is necessary to use table.SaveToStream and .LoadFromStream.
alogrep
Posts: 52
Joined: Fri Oct 27, 2006 5:25 pm

yes as far I know. But it does not work

Post by alogrep »

Hi

I have a form (myeditor) with RichViewEdit.
in this form, in the public section I have
var
editortable: TRVTableItemInfo;

In ANOTHER form, I have a function:

myeditor:=TMyEditor.Create(Self);
try
createAtable(myeditor.editortable,myeditor.RichViewEdit1)

where createatable(var table: TRVTableItemInfo; var richviewedit1: TRichViewEdit)
creates the table like this:
table := TRVTableItemInfo.CreateEx(L.count+1,7, RichViewEdit1.RVData);
and loads it like this:
table.Cells[0,0].Addnl(lg('Date'),5,0);. I check, 5 is the RVstyle that has the bold style in it, at runtime it shows that richviewedit1.TextStyles[5].style=[fsbold], at this point.

Inside myeditor, I have
procedure TMyEditor.FillFields(RVData: TCustomRVData);

where I do this:

n := RVData.GetItemTag(i);
FieldName := PChar(n);
if (FieldName<>'') and not isblank(rvdata.items) then begin
if FieldName = 'Details' then begin
table := TRVTableItemInfo.CreateEx(editortable.Rows.Count,editortable.Rows[0].Count, RichViewEdit1.RVData);
Stream := TMemoryStream.Create;
editortable.SaveToStream(Stream);
Stream.Position := 0;
editortable.free;
table.LoadFromStream(Stream);
Stream.Free;
table.ParaNo := RVData.GetItemPara(i);
RVData.DeleteItems(i, 1);
s := '';
table.Inserting(RVData, s, False);
RVData.Items.InsertObject(i, s, table);
table.Inserted(RVData, i);
if (i>0) and (RVData.GetItemStyle(i-1)=rvsListMarker) then begin
dec(i);
RVData.DeleteItems(i, 1);
end;
end;
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

this code will work properly only if the both editors are linked to the same rvstyle (or to rvstyles with the same collections of styles).
Table.SaveToStream only saves the fact what the first item in the cell has the 5th style. But properties of this style are not saved. If in the destination editor this style has different properties, they will be used.
Post Reply