windowsforms-devexpress-dot-xtrarichedit-dot-richeditcontrol-c1a5b4f6.md
Gets or sets whether the control’s content was modified since it was last saved.
Namespace : DevExpress.XtraRichEdit
Assembly : DevExpress.XtraRichEdit.v25.2.dll
NuGet Package : DevExpress.Win.RichEdit
[Browsable(false)]
[DefaultValue(false)]
public bool Modified { get; set; }
<Browsable(False)>
<DefaultValue(False)>
Public Property Modified As Boolean
| Type | Default | Description |
|---|---|---|
| Boolean | false |
true if the control’s content was modified since it was last saved; otherwise, false.
|
The following actions change the Modified property value:
The RichEditControl.SaveDocument, RichEditControl.SaveDocumentAs or Document.SaveDocument method call does not automatically change the Modified property value. However, the SaveDocumentCommand or SaveDocumentAsCommand execution changes the Modified property value to false.
When the Modified property value is changed, the RichEditControl.ModifiedChanged event raises.
The code sample below checks the Modified property in the RichEditControl.DocumentClosing event handler and shows the message box with the question whether to save changes before the application is closed.
void richEditControl_DocumentClosing(object sender, CancelEventArgs e)
{
if (RichEdit.Modified)
{
string currentFileName = RichEdit.Options.DocumentSaveOptions.CurrentFileName;
string message = !string.IsNullOrEmpty(currentFileName) ?
string.Format("Do you want to save the changes you made for '{0}'?", currentFileName) : "Do you want to save the changes?";
DialogResult result = XtraMessageBox.Show(message, "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
if (result == DialogResult.Yes)
RichEdit.SaveDocument();
e.Cancel = result == DialogResult.Cancel;
}
}
Private Sub richEditControl_DocumentClosing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
If RichEdit.Modified Then
Dim currentFileName As String = RichEdit.Options.DocumentSaveOptions.CurrentFileName
Dim message As String = If(Not String.IsNullOrEmpty(currentFileName), String.Format("Do you want to save the changes you made for '{0}'?", currentFileName), "Do you want to save the changes?")
Dim result As DialogResult = XtraMessageBox.Show(message, "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)
If result = DialogResult.Yes Then RichEdit.SaveDocument()
e.Cancel = result = DialogResult.Cancel
End If
End Sub
The following code snippets (auto-collected from DevExpress Examples) contain references to the Modified property.
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.
how-to-use-richeditcontrol-in-bound-mode/CS/Form1.cs#L27
void Cars_ColumnChanged(object sender, DataColumnChangeEventArgs e) {
if (!richEditControl1.Modified)
e.Row.AcceptChanges();
winforms-richeditcontrol-common-api/CS/RichEditAPISample/CodeExamples/RichEditControlActions.cs#L592
base.ExecuteCore();
if(!(this.Control as RichEditControl).Modified) {
MessageBox.Show("Document is saved successfully");
how-to-use-richeditcontrol-in-bound-mode/VB/Form1.vb#L25
Private Sub Cars_ColumnChanged(ByVal sender As Object, ByVal e As DataColumnChangeEventArgs)
If Not richEditControl1.Modified Then e.Row.AcceptChanges()
End Sub
winforms-richeditcontrol-common-api/VB/RichEditAPISample/CodeExamples/RichEditControlActions.vb#L606
MyBase.ExecuteCore()
If (Not TryCast(Me.Control, RichEditControl).Modified) Then
MessageBox.Show("Document is saved successfully")
See Also