RichTextBox中绘制一个RTF线 [英] Richtextbox draw an rtf line

查看:474
本文介绍了RichTextBox中绘制一个RTF线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个水平线添加到RichTextBox的作为我的文字分隔符。
我发现执行一行代码RTF一些例子,他们试图以这种方式:

I want to add a horizontal line to the RichTextBox as a delimiter of my text. I've found some examples of RTF code implementing a line and tried them in that way:

rtbResFile.Rtf = @"{\rtf1{\pard some text.\par}{\pard \brdrb \brdrs \brdrw10 \brsp20 \par}{\pard \par}{\pard some other text.\par}}";

这方法实现创建具有边框空白段落,所以应该看起来像一条线。然而,它并没有显示任何东西。只是一个空白段落。
即使我尝试实现它的方式包括行对象

This way implements creating a blank paragraph with border, so that should looks like a line. However it doesn't show anything. Just a blank paragraph. Even if I try to implement it in the way include line object

{\rtf1
{\pard some text.\par}
{\pard {\*\do\dobxcolumn\dobypara\dodhgt
        \dpline\dpxsize9200\dplinesolid\dplinew30}\par}
{\pard some other text.\par}
}

它仍然显示什么。是否RichTextBox的支持呢?或任何其他方式包括在RTF格式字符串的水平线?

It still shows nothing. Does RichTextBox supports this? Or any other ways include the horizontal line in the rtf string?

推荐答案

有几种不同的方式来创建一条水平线RTF。根据控制或程序正在使用您的里程可能会有所不同。在控制和计划RTF实现往往简单地忽略标记,他们不知道该如何处理。

There are a few different ways to create a horizontal line in RTF. Depending on the control or program being used your mileage may vary. RTF implementations in controls and programs tend to simply ignore markup that they don't know how to deal with.

通过绘制多边形:

{\pard{\*\do
\dobxcolumn \dobypara \dodhgt7200
\dpline \dpptx0 \dppty0 \dpptx7200
\dppty0 \dpx0 \dpy0 \dpxsize7200
\dpysize0 \dplinew15
\dplinecor0 \dplinecog0 \dplinecob0 }\par}

通过插入一个带有边框跟另一个空白段落没有边框的空白段落:

By inserting a blank paragraph with a border followed by another blank paragraph without a border:

{\pard \brdrb \brdrs \brdrw10 \brsp20 \par}
{\pard\par}

您可以通过在段设定缩进改变positionof行的规模和明显的:

You can change the size and apparent positionof the line by setting indents on the paragraph:

{\pard \li2268 \ri567
\brdrb \brdrs \brdrw10 \brsp20 \par}
{\pard\par}

我强烈推荐O'Reilly的RTF口袋指南这个东西,这也正是这个是从哪里来的工作。

I highly recommend O'Reilly's RTF Pocket Guide for working with this stuff, which is where this came from.

一些进一步的实验产生下面的代码,它在写字板工作和RichTextBox控件。

Some further experimentation produced the code below, which does work in WordPad and the RichTextBox control.

{\pict\wmetafile8\picw26\pich26\picwgoal20000\pichgoal15 
0100090000035000000000002700000000000400000003010800050000000b0200000000050000
000c0202000200030000001e000400000007010400040000000701040027000000410b2000cc00
010001000000000001000100000000002800000001000000010000000100010000000000000000
000000000000000000000000000000000000000000ffffff00000000ff040000002701ffff0300
00000000
}

基本上,它涉及将一个黑点的一个1x1像素的图像,并根据需要通过调节高度和宽度的目标拉伸。我们的目标测量缇。缇被定义为一英寸的1/1440。这是一个可怕的黑客,但很有效。

Basically, it involves inserting a 1x1 pixel image of a black dot and stretching it as needed by adjusting the height and width goals. The goal measurement is in twips. A twip is defined as being 1/1440 of an inch. It's a horrible hack, but it works.

这篇关于RichTextBox中绘制一个RTF线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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