Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Create a New Document

The RichEditControl.CreateNewDocument method is used to create a new document in the RichEditControl. The CreateEmptyDocumentCommand command associated with the CTRL-N key combination is also used for this purpose.

richEditControl1.CreateNewDocument();

The RichEditControl.EmptyDocumentCreated event is raised after a new document is created.

Tip

A complete sample project is available in the DevExpress Code Examples database at https://supportcenter.devexpress.com/ticket/details/e1398/how-to-specify-default-document-formatting.

Note

You can set the RichEditControl.Text property to an empty string to clear the control’s content.

The Document.DefaultCharacterProperties and the Document.DefaultParagraphProperties properties enable you to specify default formatting for the newly created document.

You can also use the RichEditControl.LoadDocumentTemplate method to load a document and leave the DXRichEditDocumentSaveOptions.CurrentFileName and the DXRichEditDocumentSaveOptions.CurrentFormat intact. Thus, the document will not be automatically overwritten if the SaveDocumentCommand command is executed or the RichEditControl.SaveDocument is called. An attempt to save a document that was loaded as a template invokes the Save As… dialog, which enables the end-user to specify a different file name and format.