devxlogo

Rich text set default font

Rich text set default font

Question:
How do I control the font size in a rich text edit? I am pulling text from a variable and applying it to a rich text edit by:

rte_1.SelectTextAll()rte_1.ReplaceText (ls_text)

Under PB 5.0 one font is used, and under PB 6.5 another font is used. Can I control the font size and type?

Answer:
You need to default the font in the RTF control by loading a piece of RTF into the control before you paste in your text.

The best way to do this is to switch on the RTF toolbar, create a single space, and set the font and height you want. Save the RTF to disk and then copy the resulting rtf file into the clipboard. Set this copied text into a variable in your code so that when the window opens the RTF code is pasted into the control.

Then when you paste in your plain text it will be the correct font.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist