代码之家  ›  专栏  ›  技术社区  ›  ARV

带richTextBox的DevExpress报表

  •  1
  • ARV  · 技术社区  · 15 年前

    我使用WPF RichTextBox来记录数据并将其保存在数据库中。现在,当我从数据库中检索相同的back并尝试在DevExpress报表中显示详细信息时,RichTextBox值将显示为一行文本,不带换行符、新行或表格格式。这就是我要做的

    将FlowDocument转换为byte[]以保存在数据库中。

    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();
                    }
                }
    

        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;
    
                            }
    
    0 回复  |  直到 15 年前