Skip to main content

RichEditControl.CreateNewDocument(Boolean) Method

Creates and loads a new empty document. Optionally, raises the DocumentClosing event.

Namespace: DevExpress.XtraRichEdit

Assembly: DevExpress.XtraRichEdit.v24.2.dll

Declaration

public virtual bool CreateNewDocument(
    bool raiseDocumentClosing = false
)

Optional Parameters

Name Type Default Description
raiseDocumentClosing Boolean False

true, to raise the RichEditControl.DocumentClosing event; otherwise, false.

Returns

Type Description
Boolean

true if a new document is created and loaded; otherwise, false.

Remarks

The CreateNewDocument helps prevent users from losing unsaved changes when a new document is created.

If the raiseDocumentClosing parameter is set to true and the RichEditControl’s document has unsaved changes (the RichEditControl.Modified property is true), the RichEditControl.DocumentClosing event is fired.

By handling the DocumentClosing event, you can set e.Cancel to true to cancel unloading a document. A new document will not be created and the CreateNewDocument method returns false.

If the new document was created and successfully loaded, the CreateNewDocument method returns true.

Example

The following code creates a new empty document with default formatting.

The RichEditControl instance is passed to the BarItem.ItemClick event handler using the BarItem.Tag property.

View Example

static void buttonCustomAction_ItemClick_NewDocument(object sender, ItemClickEventArgs e) {
    RichEditControl richEdit = e.Item.Tag as RichEditControl;
    richEdit.CreateNewDocument();
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the CreateNewDocument(Boolean) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also