RichTextBox中的HTML格式 [英] HTML Formatting in RichTextBox
问题描述
So
例如
< p>这是一个< strong> HTML< / strong>来自< em> XML的字符串< / em>文件< / p为H.
或
< p>这是我们的< span style =text-decoration:underline;>回应< / span>< / p>
应显示在richtextbox中,如下所示:
这是一个来自 XML 文件的 HTML 字符串。
这是我们的回应< - 这应该加下划线
我不太清楚如何去处理这个。而且我不太确定WebBrowser类是如何工作的,因为HTML字符串是单独的,并且不会形成完整的HTML文件。此外,我需要一种方法来反转格式(HTML编码),一旦在richtextbox中进行了任何更改,因为它们将被写回XML文件。
我有办法达到这个目的吗?我真的可以使用帮助。我很难过
编辑:
如果有帮助,这里是XML的一部分我得到我的字符串(类似于这个)。
< Field id =13598type =1>& lt; p& gt;& lt ; strong& gt;这个& lt; / strong& gt;是我们的< em& gt;响应& lt; / em& gt;& lt; / p& gt;< / Field>
我基本上试图让用户编辑和保存Field中的字符串。
编辑2:
我设法使用WebBrowser控件有点满足我的要求,但是我面临一个新的问题。看看这里:
用所见即所得的编辑器编辑HTML
任何帮助将不胜感激!
我已经使用所见即所得的HTML编辑器。但是,我正面临着一个新的问题,如果有人能够帮助,那就太棒了!
这是我的新问题:
用WYSIWYG编辑器编辑HTML
I've been working with HTML strings obtained from an XML file. I'm trying to figure out a way to display these strings in a richtextbox with formatting. So e.g.
<p>This is a <strong>HTML</strong> string from the <em>XML</em> file</p>
or
<p>This is our <span style="text-decoration: underline;">response</span></p>
Should be displayed in the richtextbox like so:
This is a HTML string from the XML file
This is our response <<-- this should be underlined
I'm not too sure how to go about with this. And I'm not too sure as to how the WebBrowser class would work here as the HTML strings are individual, and won't form a complete HTML file.
Additionally, I need a way to reverse the formatting (HTML encode) once any changes are made in the richtextbox as they'll be written back to the XML file.
Is there a way for me to achieve this? I really could use the help. I'm stumped.
EDIT:
If it helps, here's the part of the XML where I get my strings from (something similar to this).
<Field id="13598" type="1"><p><strong>This </strong>is our <em>response</em></p></Field>
I'm basically trying to allow users to edit and save the string in Field.
EDIT 2:
I've managed to use a WebBrowser control to sort of fulfill my requirements, but I'm facing a new problem. Have a look here: Editing HTML with a WYSIWYG Editor Any help would be greatly appreciated!
I've solved it using a WYSIWYG HTML editor. However, I'm facing a new problem, if anyone could help, that'd be great!
Here's my new question: Editing HTML with a WYSIWYG Editor
这篇关于RichTextBox中的HTML格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!