简体   繁体   中英

Displaying and editing HTML code in a DataGridView

I have a DataGridView that is bound to a DataSet. The DataSet has its data from an XML file. In the XML file there is one element that contains basic html data (only <p> and <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> ). When I save this xml back, the tags are converted to their html entities.

How can I display the html code as rich text in the textbox ("Some text .")? I guess I need to make a custom richtextbox column type here but I'm a little bit stuck as beginner. 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. I finally made it a regular text field that is editable in a separate form.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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