RichTextBox控件令人头疼 [英] RichTextBox control giving headaches

查看:76
本文介绍了RichTextBox控件令人头疼的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我只是在谷歌搜索和研究时碰壁,所以我来找你:)

我做了一个看起来像富文本编辑器的控件.我所做的是,我只是在用户控件中放置了一个扩展的RichTextBox,并添加了一些按钮.它像一种魅力.现在,这样做是为了支持向我们的客户数据添加描述.转到DevEx报表时,该描述会被提取.在我的DevEx报告中,我还具有RichTextBox控件(当然是报告控件:)).就是介绍了!

当客户端开始在控件中切换时会发生问题.您会看到,他想在左边排队,例如说文章,然后在右边跳出标签并写下价格.他在我的控制下做到了,但是一旦到达DevEx,制表符就会变得混乱不堪,最终我得到的文字没有对齐.当我将文本复制/粘贴到单词时也会发生这种情况.

我联系了DevEx团队,他们说这是设计使然! DevEx控件和Word显然使用GDI +编写和测量字符串,而RichTextBox使用GDI!

就是这些令人毛骨悚然的加号"弄乱了我的工作.

你能帮我吗!?您有什么建议吗?

我想要实现的是:当我查看选项卡和制表位时,我希望我在richTextBox中编写的文本在Word中是相同的!字体,大小,颜色不是问题.是导致头痛的标签!

请大家帮忙!

问候,

Hi guys,

I just hit the wall with googling and researching so I come to you :)

I made a control that should look like rich text editor. What I did is, I just placed an extended RichTextBox in my user control and added some buttons. It works like a charm. Now this was made to support adding a description to our clients data. That description gets pulled when going to DevEx report. On my DevEx report I also have RichTextBox control(report control of course :) ). That''s it for the intro!

Problems happen when the client starts to tab off in the control. You see, he wants to line up, lets say, articles on the left and than tab off to the right and write prices. And he does that in my control, but as soon as it gets to DevEx tab stops get mixed up and I end up with not-lined-up text. This also happens when I copy/paste the text to word.

I contacted DevEx team and they say it''s by design! DevEx control and Word, apparently use GDI+ to write and mesaure strings and RichTextBox uses GDI!

It''s this darn "plus" that is messing my work.

Can you help!? Do you have any suggestions?

What I want to achieve is: I want the text I wrote in richTextBox to be the same in Word when I look at the tabs and tab stops! Font, size, color is not the problem. It''s tabs that cause the headache!

Please help guys!

Regards,

推荐答案

首先,不要伪造,Tab也用于导航.使用System.Windows.Controls.RichTextBox.AcceptsTab来控制此行为.自己决定自己随时喜欢什么:标签导航或文档中的标签字符.

现在,文档中的选项卡从来都不是用于对齐列之类的可靠工具.通过设计!
原则上,有一种使用Word表的方法,但这非常微妙.
阅读此线程: http://social.msdn. microsoft.com/forums/zh-CN/winforms/thread/38f8618e-5532-4e55-b7c0-24d10749f99c [ http://www.go4answers.com/Example/seletedrtf-rich-text-box-build-tables-33280.aspx [ ^ ].

CodeProject成员 Pete O''Hanlon 有一个有趣的答案,但我从来没有测试了它:在richtextbox中创建表 [
First, don''t forger, Tab is also used for navigation. Use System.Windows.Controls.RichTextBox.AcceptsTab to control this behavior. Decide for yourself what do you prefer at every moment: Tab navigation or Tab character in the document.

Now, Tabs in the document had never been a reliable tool for aligning columns or something like that. By design!
In principle, there is a way to use Word tables, but this is very subtle.
Read this thread: http://social.msdn.microsoft.com/forums/en-US/winforms/thread/38f8618e-5532-4e55-b7c0-24d10749f99c[^], and this one: http://www.go4answers.com/Example/seletedrtf-rich-text-box-build-tables-33280.aspx[^].

There is an interesting answer of the CodeProject member Pete O''Hanlon, but I never tested it: Create a table in richtextbox[^]; you may want to ask him for more detail.

—SA


这篇关于RichTextBox控件令人头疼的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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