Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hi.

                                    In the RichEdit control I am looking for a simple way to convert a formatted text to a plain text and keep this text into the control.

                                    Thanks
                                    M.

                                1 Solution

                                Creation Date Rating Importance Sort by
                                0
                                Hello Mirko,

                                You can use the editor's Text property to accomplish this task. For example:
                                [Delphi]
                                cxRichEdit1.EditValue := cxRichEdit1.Text;
                                Show all comments
                                • Mirko C. 01.09.2017
                                  Sorry Paulo, my fault :-/
                                  I meant the RichEditControl where I was looking for something like the EditValue like the RichEdit.

                                  I tried
                                  [Delphi]

                                  dxRichEditControl.Document.Text := dxRichEditControl.Document.GetText(); 
                                  but it doesn't affect the control and all the formats still remain.
                                • You can use an intermediate stream to load/save required data between TcxRichEdit and TdxRichEditControl instances. Attached is a small sample project demonstrating this approach in action.

                                • Mirko C. 01.11.2017
                                  Thank you Paulo. It works fine!
                                  Just a last question. When restoring the plain text, the font is inherited from its parent. which in my case is the main form.
                                  Is it possible to customize for the TcxRichEditControl directly?
                                  Mirko
                                • You can use the ARichEdit.Style.Font property to customize this form. For example:
                                  [Delphi]
                                  var AStream: TMemoryStream; ARichEdit: TcxRichEdit; begin AStream := TMemoryStream.Create; ARichEdit := TcxRichEdit.Create(Self); try ARichEdit.Visible := False; ARichEdit.Parent := Self; ARichEdit.EditValue := dxRichEditControl1.Document.Text; ARichEdit.Style.Font.Name := 'Arial'; ARichEdit.Style.Font.Size := 24; ARichEdit.Lines.SaveToStream(AStream); AStream.Position := 0; dxRichEditControl1.LoadDocument(AStream, TdxRichEditDocumentFormat.Rtf); finally AStream.Free; ARichEdit.Free; end;
                                • Mirko C. 01.12.2017
                                  Thanks Paulo. So I do also this on the cxRichEdit level... now it's clear.
                                  Now a curiosity. When I start the form, the dxRichEditControl have as font Calibri 11 that is not set in any of the components but it's my standard font and size for my office applications (outlook, word, ecc.). I suppose there is a connection between this two settings? So set a starting font and size can be done only by using a intermediate trick with an empty text property?
                                  Thanks Mirko
                                • You can use the following code to directly change default font settings in the Rich Edit Control:
                                  [Delphi]
                                  dxRichEditControl1.Document.DefaultCharacterProperties.FontName := 'Arial'; dxRichEditControl1.Document.DefaultCharacterProperties.FontSize := 40;

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, ASP.NET, WinForms, HTML5 or Windows 10, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2017 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners