Page 1 of 1

Default Font for DBRichviewedit

Posted: Mon Mar 12, 2007 8:47 pm
by carloscastro
Hi,

How can i set the default font in a DBRichview edit.
Whenever i create a new record in a database and use dbrichview to edit a text field it assumes verdana font as default.
How can i change this.

Thanks.

Posted: Tue Mar 13, 2007 12:02 pm
by j&b
Click TDBRichViewEdit/Ereignisse/OnNewDocument

procedure TForm1.memoNewDocument(Sender: TObject);
begin
rvs.TextStyles.clear; rvs.ParaStyles.clear; rvs.ListStyles.clear;
rvs.TextStyles.add; rvs.TextStyles[0].FontName:='Arial';
rvs.TextStyles[0].Size := 11;
rvs.PageBreakColor:=clRed;
rvs.ParaStyles.add; rvs.ParaStyles[0].alignment:=rvaLeft;
rvs.ParaStyles.add; rvs.ParaStyles[1].alignment:=rvaCenter;
rvRuler1.leftMargin:=0.1;
RVRuler1.Width:=memo.Width;
rvRuler1.rightMargin:=4;
end;

Posted: Tue Mar 13, 2007 2:38 pm
by Sergey Tkachenko
Yes, use OnNewDocument event to create default set of styles. Clear collections of text, paragraph and list styles, then add at least one text and at least one paragraph style. TextStyles[0] and ParaStyles[0] define default properties. Of course, this RVStyle must be used only by this TDBRichViewEdit, and styles must be saved in documents (right click DBRichViewEdit in Delphi, choose "Settings" in the popup menu, make sure that "Allow adding styles dynamically" is set.

As for the ruler (if you use it), I believe it will be updated automatically.

Posted: Tue Mar 13, 2007 7:40 pm
by carloscastro
Ok...

Many thanks...it works

Thanks