如何发送从一个RichTextBox的不同大小的文本串到另一个? [英] How do I send varying text sized strings from one RichTextBox to another?

查看:133
本文介绍了如何发送从一个RichTextBox的不同大小的文本串到另一个?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有code,它具有对标小字体化合物。目前,我有这个code转移了从一个的RichTextBox 来点击一个按钮一个又一个。

I have code that has chemical compounds that have small font for the subscript. I currently have this code that transfers it from one RichTextBox to another one on a Button click.

myRichTextBox.Text += otherRichTextBox.Text

otherRichTextBox 我用不同字体的化合物,但是尺寸我做到这一点我结束了在 myRichTextBox 不保持不同的字体大小和它们全部设置在箱子上主要属性的字体和大小。

In otherRichTextBox I have the compound with varying font sizes however when I do this I end up with a string in myRichTextBox that doesn't keep the varying font sizes and sets them all to the boxes main properties font and size.

推荐答案

从的在MSDN文档

Text属性不返回有关应用于RichTextBox的内容格式的任何信息。要获得丰富文本格式(RTF)codeS,使用RTF属性。

"The Text property does not return any information about the formatting applied to the contents of the RichTextBox. To get the rich text formatting (RTF) codes, use the Rtf property."

所以要赋值,包含格式,使用:

So to assign the value, with formatting, use this:

myRichTextBox.Rtf = otherRichTextBox.Rtf;

我把它换成 + = = ,因为我不知道你的意思追加的价值,而不仅仅是更换。如果你使用 + = ,你可能会由于RTF格式codeS被追加一前一后遇到的问题。然而,试试看......你可能根本不遇到任何问题。

I've replaced += with = because I'm not sure you meant to append the value, rather than just replace it. If you do use +=, you may run into issues due to the "rtf" codes being appended one after the other. However, give it a try... you may not run into any issues at all.

这篇关于如何发送从一个RichTextBox的不同大小的文本串到另一个?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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