WPF RichTextControl语法突出显示问题 [英] WPF RichTextControl syntax highlighting problem

查看:162
本文介绍了WPF RichTextControl语法突出显示问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,程序员!我在WPF中遇到RichTextCtrl问题.我的应用程序创建了课程,将它们保存在sql数据库中,然后可以将它们读回.保存它们时,我希望标题和某些部分的颜色不同.因此,我将标题保存在db中,例如:

Hello, programmers! I''m experiencing trouble with RichTextCtrl in WPF. My application creates lessons, saves them in sql database and then can read them back. When saving them, I prefer the title and some parts to be colored differently. So i save the title in db like:

<t>Lesson1</t>

,并且在读取时再次以这种方式显示.

我需要获取标签之间的文本,然后为其着色.问题是我怎么能得到文本.在此先感谢您的帮助:)

and when read it it shows in this way again.

I need to get the text between tags and then color it. The problem is how i can get the text. Thanks in advance for any help :)

推荐答案

本文可能会为您提供帮助: ^ ]

我认为您可能也觉得这很有用: RichTextBox概述 [ Rich Text Format(RTF)Specification,版本1.8 [^ ]-您可以使用Microsoft Word编辑课程,添加一些导入工具,然后使用自己的应用程序进行显示.

基本上,如果您想保留格式信息,则需要读写RTF,而不仅仅是文本,或者使用 ^ ]

最好的问候
Espen Harlinn
This article may help you: WPF RichTextBox: How To Load, Edit and Save Rich Text Format[^]

I think you may also find this quite useful: RichTextBox Overview[^]

And finally you should read: Rich Text Format (RTF) Specification, version 1.8[^] - as you can use Microsoft Word to edit your lessons, add some import facility, and then use your own application for display purposes.

Basically you need to read and write RTF, and not just the text, if you want to keep the formatting information - or work with the FlowDocument Class[^]

Best regards
Espen Harlinn


此控件的名称既不是RichTextCtrl也不是RichTextControl,而是RichTextBox.我建议看一下不同的控件.下载SharpDevelop的源代码,请参见 http://en.wikipedia.org/wiki/SharpDevelop [ http://sharpdevelop.com/OpenSource/SD/Default.aspx [ http://sharpdevelop .com/OpenSource/SD/Download/GetFile.aspx?What = Source& Release = Mirador [
This control''s name is neither RichTextCtrl nor RichTextControl, it''s RichTextBox. I would recommend to look at different control. Download source code of SharpDevelop, see http://en.wikipedia.org/wiki/SharpDevelop[^], http://sharpdevelop.com/OpenSource/SD/Default.aspx[^].

This is the download of the source code for v.4: http://sharpdevelop.com/OpenSource/SD/Download/GetFile.aspx?What=Source&Release=Mirador[^].

It has a powerful customizable text editor with syntax highlight.

—SA


这篇关于WPF RichTextControl语法突出显示问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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