Reputation: 1141
I am using WPF RichTextBox to record data and save the same in database. Now when i retrieve the same back from database and try to show the detail in a DevExpress report RichTextBox value appears as a single line of text without line break or new lines or table format. This is what i am doing
Converting FlowDocument to byte[] to save in database.
var content = new TextRange(flowDocument.ContentStart, flowDocument.ContentEnd);
if (content.CanSave(DataFormats.Rtf))
{
using (var stream = new MemoryStream())
{
content.Save(stream, DataFormats.Rtf);
return stream.ToArray();
}
}
Converting byte array to text to display in report
FlowDocument doc = new FlowDocument();
string rtfText = null;
using (MemoryStream stream = new MemoryStream(byteArrayValue))
{
TextRange text = new TextRange(doc.ContentStart, doc.ContentEnd);
text.Load(stream, DataFormats.Text);
rtfText = text.Text;
}
Upvotes: 2
Views: 2100
Reputation: 61
[!private void tableCell19_EvaluateBinding(object sender, DevExpress.XtraReports.UI.BindingEventArgs e) { e.Value = string.Join(Environment.NewLine, e.Value.ToString().Split(',')); }
enter image description here]1
you can use this script in DevExpress report deisgner.
Upvotes: 0