Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

RichTextBox Error on Save and Retrieve PLEASE SAVE ME

$
0
0

Hello,

Ive been having a stress ful problem for the past three days.

I have an Richtextbox in a page and a list on another page. When you select a list item it should load the next page and add the rtf.

Well it loads but when i make changes to the rtf and save it saves but if I load tht rtf again the changes are not there then if I load three four times the information is different all the time.

I've tried even SQL query

Save RTF

TextRange textRange = new TextRange(rtfNotes.Document.ContentStart, rtfNotes.Document.ContentEnd);           
            MemoryStream ms = new MemoryStream();
            textRange.Save(ms, DataFormats.Rtf);
            string SQLData = ASCIIEncoding.Default.GetString(ms.ToArray());
            tblConsultation ct = (from b in conn.tblConsultations
                                 where b.ConsultationID == ConsultationID
                                 select b).Single<tblConsultation>();
            ct.Notes2 = SQLData;       
            conn.SubmitChanges();

Load Rtf

 TextRange tr = new TextRange(rtfNotes.Document.ContentStart, rtfNotes.Document.ContentEnd);
            MemoryStream ms10 = GetMemoryStreamFromString1(notesSQL);
            tr.Load(ms10, System.Windows.DataFormats.Rtf);

        private MemoryStream GetMemoryStreamFromString1(string s)
        {
            if (s == null || s.Length == 0)
                return null;
            MemoryStream m = new MemoryStream();
            StreamWriter sw = new StreamWriter(m);
            sw.Write(s);
            sw.Flush();
            return m;
        }


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>