RichTextBox 控件的 Windows 窗体 RTF 格式

发布于 2024-10-02 13:23:04 字数 477 浏览 5 评论 0原文

我正在开发一个 Windows 窗体应用程序,我希望有一个富文本框显示基于不同对象触发的事件的状态。我希望能够在项目进入 rtb 时使用 rtf 属性对其进行格式化,以便可以通过更改字体粗细和颜色轻松区分它们。

该格式将包含

<b><datetime></b> - <colored text>Event Type</colored text> - <plain text>Event Details</plain text>

我对 RTF 进行了大量研究,这似乎是可能的,但将格式下来很困难。据我所知,我需要输入一个带有非常具体标签的标题才能使其首先工作。

似乎要跳过很多环节才能让它工作,如果我能找到一个可以在 rtb 中输入文本、格式化它,然后单击按钮并返回 rtf 的网站,那就太好了通过这种方式生成,我就能很好地了解我必须做什么才能让它发挥作用。

I'm working on a windows form application and I want to have a rich text box display the status of events that are firing based on different objects. I want to be able to format the items as they come into the rtb using the rtf property so that they can be easily distinguished from each other by changing font weight and color.

The format would contain

<b><datetime></b> - <colored text>Event Type</colored text> - <plain text>Event Details</plain text>

I've been doing a lot of research on RTF and it appears to be possible, but getting the formatting down is difficult. From what I can find I need to enter a header with very specific tags for it to work in the first place.

It seems like a lot of hoops to jump through just to get it to work and it would be nice if I could find a site where i could enter text into rtb, format it, and then click a button and get back the rtf that is generated that way I would have a good idea of what I would have to do to get this to work.

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

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

发布评论

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

评论(1

铁憨憨 2024-10-09 13:23:04

过去,我使用写字板获取小块 RTF 以在 RichTextBox 中使用。

开始>节目>配件>写字板

所以上面的文本让你在 rtf 中得到这个

{\rtf1\ansi\ansicpg1252\deff0\deflang6153{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\colortbl ;\red255\green0\blue0;}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\b\f0\fs22 Datetime\b0  - \cf1 Event Type\cf0  - Event Details\par
}

然后修改这些代码(或理解 rtf ;-)来获得你需要复制到 Rtf 属性中的布局。

热值

In the past, I have used WordPad to get small chuncks of RTF to use in an RichTextBox.

Start > Programs > Accessories > WordPad

So the above text gets you this in rtf

{\rtf1\ansi\ansicpg1252\deff0\deflang6153{\fonttbl{\f0\fnil\fcharset0 Calibri;}}
{\colortbl ;\red255\green0\blue0;}
{\*\generator Msftedit 5.41.21.2509;}\viewkind4\uc1\pard\sa200\sl276\slmult1\lang9\b\f0\fs22 Datetime\b0  - \cf1 Event Type\cf0  - Event Details\par
}

It is then a matter of tinkering with these codes (or understanding rtf ;-) to get the layout you need to copy into the Rtf property.

Hth

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