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 http://www.devexpress.com/example=E1398.

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.