RichTextBox字体设置为C#中的所有行 [英] RichTextBox font set to all lines in C#

查看:181
本文介绍了RichTextBox字体设置为C#中的所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我改变了 RichTextBox ,但是这个改变并没有正确设置所有的字符。确实存在RichTextBox的两种字体,这并不美观。有没有这个问题的解决方案!

I changed the font of a RichTextBox, but this change does not set to all of its characters properly. Indeed there exist two font for the RichTextBox and that is not beautiful. Is there a solution for this problem!?

这段代码无法正常工作:

This code does not work correctly:

this.richTextBox1.Font = new System.Drawing.Font("Maiandra GD", 12);


推荐答案

将所选内容设置为整个框并设置SelectionFont 。

Set the selection to the entire box and set the SelectionFont.

this.richTextBox1.SelectionStart = 0;
this.richTextBox1.SelectionLength = this.richTextBox1.SelectionLength;
this.richTextBox1.SelectionFont = new System.Drawing.Font("Maiandra GD", 12);

这篇关于RichTextBox字体设置为C#中的所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆