简体   繁体   English

在DataGridView中显示和编辑HTML代码

[英]Displaying and editing HTML code in a DataGridView

I have a DataGridView that is bound to a DataSet. 我有一个绑定到数据集的DataGridView。 The DataSet has its data from an XML file. DataSet的数据来自XML文件。 In the XML file there is one element that contains basic html data (only <p> and <strong> ): 在XML文件中,有一个元素包含基本的html数据(仅<p><strong> ):

<?xml version="1.0" encoding="utf-8"?>
<entries>
    <entry>
        <desc><![CDATA[[<p>Some <strong>text.</strong></p>]]></desc>
    </entry>
</entries>

When I have a DataGridView that has a column bound to this field desc the html gets displayed as string with its tags ( <p>Some <strong>text.</strong></p> ). 当我有一个DataGridView的列绑定到此字段desc ,html就会显示为带有标签的字符串( <p>Some <strong>text.</strong></p> )。 When I save this xml back, the tags are converted to their html entities. 当我保存该xml时,标记将转换为它们的html实体。

How can I display the html code as rich text in the textbox ("Some text .")? 如何在文本框中将html代码显示为富文本格式(“某些文本” 。)? I guess I need to make a custom richtextbox column type here but I'm a little bit stuck as beginner. 我想我需要在此处创建一个自定义的richtextbox列类型,但作为初学者,我有点受阻。 Furthermore the text should be editable with a richtexteditor. 此外,文本应该可以通过富文本编辑器进行编辑。

Can someone give me some help on this? 有人可以帮我这个忙吗?

I ended up not doing this. 我最终没有这样做。 It's not a good user experience to have a RichTextBox right in the DataGridView. 在DataGridView中拥有RichTextBox并不是良好的用户体验。 I finally made it a regular text field that is editable in a separate form. 我最终使它成为一个普通的文本字段,可以用单独的形式对其进行编辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM