在设计时是否可以在RichTextBox中设置文本样式? [英] Is it possible to style text in a richtextbox at design time?

查看:79
本文介绍了在设计时是否可以在RichTextBox中设置文本样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个System.Windows.Forms.RichTextBox,希望用于向我的应用程序用户显示一些指令。

I have a System.Windows.Forms.RichTextBox that I wish to use to display some instructions to my application users.

是否可以设置一些我在设计时输入的文本会以粗体显示吗?

Is it possible to set some of the text I enter at designtime to be bold?

还是我别无选择,只能在运行时执行?

Or do I have no option but to do it at runtime?

推荐答案

您当然可以在RTF编辑器(例如WordPad)中创建RTF文档,保存文件,将其打开为文本/纯文本文件,然后将RTF文档复制到<$ c $ RichTextBox 的c> RtfText 属性在设计时。

You can certainly create an RTF document in RTF editor (e.g. WordPad), save the file, open it as a text/plain file and copy the RTF document into the RtfText property of your RichTextBox at design time.

但我建议不要这样做它。这样,您的代码中就会包含大量数据,而这样做毫无意义。毕竟,使用资源就是他们的目的。您可以在设计时绑定单个资源以控制属性。

But I advise against it. That way, you have a large amount of data in your code and there’s just no point in doing that. Use a resource, that’s what they’re there for, after all. You can bind individual resources to control properties at design time.

这篇关于在设计时是否可以在RichTextBox中设置文本样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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