FieldKeywords.Text property

Gets or sets the text of the keywords.

public string Text { get; set; }


Shows to insert a KEYWORDS field.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Add some keywords, also referred to as "tags" in File Explorer.
doc.BuiltInDocumentProperties.Keywords = "Keyword1, Keyword2";

// The KEYWORDS field displays the value of this property.
FieldKeywords field = (FieldKeywords)builder.InsertField(FieldType.FieldKeyword, true);

Assert.AreEqual(" KEYWORDS ", field.GetFieldCode());
Assert.AreEqual("Keyword1, Keyword2", field.Result);

// Setting a value for the field's Text property,
// and then updating the field will also overwrite the corresponding built-in property with the new value.
field.Text = "OverridingKeyword";

Assert.AreEqual(" KEYWORDS  OverridingKeyword", field.GetFieldCode());
Assert.AreEqual("OverridingKeyword", field.Result);
Assert.AreEqual("OverridingKeyword", doc.BuiltInDocumentProperties.Keywords);

doc.Save(ArtifactsDir + "Field.KEYWORDS.docx");

See Also