Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document.
Syntax
public bool IsDirty { get; set; }
Public Property IsDirty As Boolean
Get
Set
public:
property bool IsDirty {
bool get ();
void set (bool value);
}
member IsDirty : bool with get, set
Property Value
Type:
Boolean
Examples
Shows how to use special property for updating field result.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
doc.BuiltInDocumentProperties.Author = "John Doe";
FieldAuthor field = (FieldAuthor)builder.InsertField(FieldType.FieldAuthor, true);
Assert.False(field.IsDirty);
Assert.AreEqual("John Doe", field.Result);
doc.BuiltInDocumentProperties.Author = "John & Jane Doe";
Assert.AreEqual("John Doe", field.Result);
field.IsDirty = true;
using (MemoryStream docStream = new MemoryStream())
{
doc.Save(docStream, SaveFormat.Docx);
LoadOptions options = new LoadOptions();
options.UpdateDirtyFields = updateDirtyFields;
doc = new Document(docStream, options);
Assert.AreEqual("John & Jane Doe", doc.BuiltInDocumentProperties.Author);
field = (FieldAuthor)doc.Range.Fields[0];
if (updateDirtyFields)
{
Assert.AreEqual("John & Jane Doe", field.Result);
Assert.False(field.IsDirty);
}
else
{
Assert.AreEqual("John Doe", field.Result);
Assert.True(field.IsDirty);
}
}
See Also