Question

I have a string with basic html markup which I want to put into a rich textbox

 string ab  = @"<b> a b </b>"

I want it to render as it would appear in a browser ie:

a b

how can I do this in active reports 7? According to http://www.datadynamics.com/forums/77664/ShowPost.aspx, a richtextbox supports these tags. Do I have to specify a property to allow it to render html? How should I approach this?

Thanks, Sam

More information (Update 8/11):

I'm binding the data from a database field - an oracle nclob. The field repeats within the detail section (with different information each time).

If I bind the field directly to a textbox or label it renders the string, but doesnt encode the html

 <b> a b </b>

but it encode the string.


Solution Summary

Solution (as suggested by @activescott)

  • Bind rtx directly to the datafield
  • 'Reformat' the text into html in the script

public void detail_Format() { rtxBox.Html = rtxBox.Text; }

result: renders the html field with some degree of html formatting

notes:

  • binding directly in the script doesnt work, ie. rtxBox.Html = pt.Fields["CONT_ID"].ToString(); yields some wierd meta data string
  • the Datafield only binding approach doesn't work (it will yield it as text)
  • there are some extra spacing that occurs with p tags. It may be worth regexing them out or somehow providing some formatting control.
Était-ce utile?

La solution

The actual property you are looking for is the Html Property. You can also load a file into that control using the step-by-step walkthrough here.

I am assuming you are using Section Reports and not Page Reports.

To use HTML from the database in a bound report, you should be able to use the DataField property of the RichTextBox control (set it to the name of the corresponding Data field at design time). However, I noticed this "Render HTML tags in DB in ActiveReport pdf or HTML" article which kind of implies that doesn't work since it loads the HTML from a database programatically. One of the two should work.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top