Page 1 of 1

Default Font Size 8 point - need default 9 point Question

Posted: Thu Oct 28, 2021 6:22 am
by alanmcd
Searched here but no answer:
I have a DBRichViewEdit with a RVStyles attached.
RVStyles has some TextStyles set, one of which is '0 - Normal Text' with SizeDouble set to 18

Now - I can insert an item (e.g. table) and beforehand search for and add a missing font size 9 - no problems there.
But for the life of me I cannot get the default font size - on an empty, newly inserted record field - to be point size 9 or sizeDouble 18. It's always point size 8.
I add a record, start typing in the field and it's always 8 point size.

How, in the simplest way possible, can I set the DBRichViewEdit to acquire a default font size 9 or sizedouble 18 whenever a new record is added using this edit component ??

thank
Alan

Re: Default Font Size 8 point - need default 9 point Question

Posted: Thu Oct 28, 2021 8:09 pm
by standay
alanmcd wrote: Thu Oct 28, 2021 6:22 am How, in the simplest way possible, can I set the DBRichViewEdit to acquire a default font size 9 or sizedouble 18 whenever a new record is added using this edit component ??
I don't use the db stuff but I think the only way you can do it is by spinning through the text styles every time you add a record:

Code: Select all

for i := 0 to rv.Style.TextStyles.Count-1 do
  rv.Style.TextStyles[i].Size := rv.Style.TextStyles[i].Size + FSize;
Sergey may have a better way so I'll see what he says, but that's how I did it in a regular RVE.

Stan

Re: Default Font Size 8 point - need default 9 point Question

Posted: Fri Oct 29, 2021 1:36 am
by alanmcd
Hmm, OK well I have decided to do it this way:

Code: Select all

  DBRichViewEdit1.DeleteUnusedStyles(True, True, True);
  for I := 0 to RVStyleEstimateItems.TextStyles.Count-1 do begin
    if (RVStyleEstimateItems.TextStyles.Items[i].Size<9) then RVStyleEstimateItems.TextStyles[i].Size:=9;
  end;
And I do that when I save my templates - that way the templates come back with no size 8 fonts

Alan

Re: Default Font Size 8 point - need default 9 point Question

Posted: Sun Oct 31, 2021 2:11 pm
by Sergey Tkachenko
Yes, you can call this procedure in DBRichViewEdit.OnNewDocument event.
You can call the code your posted in the last message, or simply create a new set of styles that will be default, such as:

Code: Select all

RVStyleEstimateItems.TextStyles.Clear;
RVStyleEstimateItems.ParaStyles.Clear;
RVStyleEstimateItems.ListStyles.Clear;
with RVStyleEstimateItems.TextStyles.Add do
begin
  FontName := 'Tahoma';
  Size := 9;
end;
RVStyleEstimateItems.ParaStyles.Add;
The code above should be used if StyleTemplates are not used, i.e. if DBRichViewEdit1.UseStyleTemplates = False.
Otherwise, you should link text and paragraph style to the StyleTemplate named "Normal" and use its attributes (I can explain how, if you need).