Default Font Size 8 point - need default 9 point Question

General TRichView support forum. Please post your questions here
Post Reply
alanmcd
Posts: 53
Joined: Mon Jun 04, 2007 12:25 pm

Default Font Size 8 point - need default 9 point Question

Post 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
standay
Posts: 274
Joined: Fri Jun 18, 2021 3:07 pm

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

Post 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
alanmcd
Posts: 53
Joined: Mon Jun 04, 2007 12:25 pm

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

Post 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
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

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

Post 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).
Post Reply