RichEditControl.Modified Property

Gets or sets whether the control's content was modified since it was last saved.

Namespace: DevExpress.XtraRichEdit

Assembly: DevExpress.XtraRichEdit.v20.1.dll

Declaration

[Browsable(false)]
[DefaultValue(false)]
public bool Modified { get; set; }
<Browsable(False)>
<DefaultValue(False)>
Public Property Modified As Boolean

Property Value

Type Default Description
Boolean

false

true, if the control's content was modified since it was last saved; otherwise, false.

Remarks

The following actions change the Modified property value:

RichEditControl and SnapControl

  • Add, delete, cut or paste content;
  • Change text format (font, paragraph properties, apply style, change direction);
  • Change document layout (insert section break, divide into columns, change margins, orientation);
  • Edit character, paragraph and table styles;
  • Insert or modify document elements (drawing objects, tables, comments, etc.);

SnapControl

  • Modify data sources stored in a document (the SnapDocument.DataSources collection items): change the name, type, etc.;
  • Modify existing CalculatedFieldCollection items;
  • Modify existing ParameterCollection items;
  • Set the data source as the SnapControl.Options.SnapMailMergeVisualOptions.DataSource property value when the Snap document contains fields from the target data source.

Changes in data sources stored at the control level (SnapControl.DataSources) do not 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;
    }
}

Implements

See Also