Solved

Default font RichText control DevExpress

  • 21 January 2023
  • 4 replies
  • 208 views

Userlevel 6
Badge +3

Hi,

 

Does anyone know how to change the default font of a RichText control in Devexpress? I have a html variable bound to it from my datasource, but instead of going for the default font set for the whole document it's presenting the data in TImes New Roman.

 

Html variable bound to it
Advies is in Times New Roman

I've found multiple custom scripts that change the font at runtime in some very old DevExpress support threads on their community, but those scripts make use of a library called RichEditDocumentServer. That library is nowhere to be found in the version of DevExpress that's available to us.

Maybe there's a way to change the font of an HTML field before we feed it to DevExpress? I've seen this solution: 

 but I don't necessarily want to change the font in the HTML editor or the column itself in Universal.

Thanks!
 

icon

Best answer by rbiram 23 January 2023, 16:23

View original

This topic has been closed for comments

4 replies

Userlevel 6
Badge +3

I've found a way to do this. In the Html expression of the RichText control you can add the following:

FormatString('<div style="font-family:Verdana; font-size:9.75pt;">{0}</div>', [column] )

The only thing that's bothering me is the extra padding in red that gets added for the <p> paragraph that's bold. Tried to overwrite it in the above code and via the following solution but it didn't work: 


Stil curious if anybody knows of another way!

Userlevel 4
Badge +5

Maybe you can add a little more css styling. Like lowering the line-height, or padding/margin from the top. 

Userlevel 4
Badge +5

If you cannot fix this with dev-express you can always try to modify the database value of the HTML field, maybe add some styling in the field itself so that there is no spacing in front of the content.

Userlevel 7
Badge +11

The only thing that's bothering me is the extra padding in red that gets added for the <p> paragraph that's bold.

 

Using a span instead of div might help.