RichTextBox font set to all lines in C#

独自空忆成欢 提交于 2019-11-28 10:25:30

问题


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);

回答1:


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);


来源:https://stackoverflow.com/questions/15554401/richtextbox-font-set-to-all-lines-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!