有没有好的“RichString”? 外面有课吗?

发布于 2024-07-13 22:15:19 字数 265 浏览 4 评论 0原文

我正在寻找一个类/API,它允许您创建和操作 RichText 字符串(rtf 格式),以便与 RichTextbox 之类的控件一起使用。

我正在考虑类似 StringBuilder 的东西,但它还允许您在附加到它时指定格式,还可以返回并编辑之前附加的段,以及执行字符串操作,例如与 .Contains() 等效的操作.IndexOf() 和字符串比较。 它可能需要一些额外的类来支持格式化功能。

有什么建议么?

I'm looking for a class/API that allows you to create and manipulate RichText strings (rtf format) for use with the RichTextbox -like controls.

I'm thinking of something like StringBuilder, but that also allows you to specify formatting as you append to it and also go back and edit previously appended segments, as well as doing string operations like like the equivalent to .Contains() or .IndexOf() and string comparisons. It may require a few additional classes to support the formatting features.

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

野却迷人 2024-07-20 22:15:19

iTextSharp 基本上是一个 PDF 生成库,但也可用于创建文件,如图所示 此处

iTextSharp is basically a PDF generation library but can also be used to create files as shown here.

女中豪杰 2024-07-20 22:15:19

为什么不添加一行并然后格式化它? 您可以创建一个使用 stringbuilder 的自定义类,但也可以在同一个子中设置文本样式(请注意,绘制后它看起来会格式化,因为它将完成子然后绘制它)
我的意思是使用选择来格式化它。 此外,我觉得编写 RTF 是一种脑死亡,因为拥有可以开箱即用的控件。

编辑:只是为了澄清,我的意思是
1. 写入行
2.选择自定义字符串生成器中使用的部分(不是通过匹配,而是通过偏移)
3. 设计它们的风格。 =)

Edit_2: 现在我想了一下,它很有可能拥有一个简化的语法。 您可以拥有一个满足您需要的子程序:

WriteIt(username, "My text")
(日期由您的子自动添加:)

Why not add a line and then format it? You can make a custom class that uses stringbuilder but also styles the text in the same sub (note that it will look fomatted as soon as drawn, since it will finish the sub and then draw it)
I mean using selection to format it. Besides, I feel writing RTF is brain-dead having the control that can do it out-of-the-box.

Edit: just to clarify, I mean
1. Write the line
2. Select the parts used in the custom stringbuilder (not by matching, but by offset)
3. Style them. =)

Edit_2: now that I think about it, it has the wonderful possibility of having a simplified sintax. You can have a sub that takes just what you need:

WriteIt(username, "My text")
(date added automatically by your sub :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文