用于RichTextBox控件的Windows Form RTF格式 [英] Windows Form RTF formatting for the RichTextBox Control

查看:159
本文介绍了用于RichTextBox控件的Windows Form RTF格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



格式将包含

 < b>< datetime>< / b> - <彩色文字>事件类型< /彩色文字> - <纯文本>事件详情< /纯文本> 

我一直在做很多关于RTF的研究,看起来可能,但得到格式化很困难。从我所能找到的,我需要输入一个非常具体的标签头来让它在第一时间工作。



看起来好像有很多箍环可以跳过让它起作用,如果我可以找到一个可以将文本输入到rtb中的格式,然后单击一个按钮并找回生成的rtf,我就可以很好地了解

解决方案

在过去,我使用写字板来获得小块的RTF在RichTextBox中使用。

开始>程序>附件>写字板



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\sl2 76 \slmult1\lang9\b\f0\fs22日期时间\ b0 - \cf1事件类型\cf0 - 事件详细信息\par
}

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

Hth


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.

解决方案

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

这篇关于用于RichTextBox控件的Windows Form RTF格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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