FieldAutoTextListEntryName Property |
Namespace: Aspose.Words.Fields
public void FieldAutoTextList() { Document doc = new Document(); // Create a glossary document and populate it with auto text entries that our auto text list will let us select from doc.GlossaryDocument = new GlossaryDocument(); AppendAutoTextEntry(doc.GlossaryDocument, "AutoText 1", "Contents of AutoText 1"); AppendAutoTextEntry(doc.GlossaryDocument, "AutoText 2", "Contents of AutoText 2"); AppendAutoTextEntry(doc.GlossaryDocument, "AutoText 3", "Contents of AutoText 3"); // Insert an auto text list using a document builder and change its properties DocumentBuilder builder = new DocumentBuilder(doc); FieldAutoTextList field = (FieldAutoTextList)builder.InsertField(FieldType.FieldAutoTextList, true); // This is the text that will be visible in the document field.EntryName = "Right click here to pick an AutoText block"; field.ListStyle = "Heading 1"; field.ScreenTip = "Hover tip text for AutoTextList goes here"; Assert.AreEqual(" AUTOTEXTLIST \"Right click here to pick an AutoText block\" " + "\\s \"Heading 1\" " + "\\t \"Hover tip text for AutoTextList goes here\"", field.GetFieldCode()); doc.Save(ArtifactsDir + "Field.AUTOTEXTLIST.dotx"); } /// <summary> /// Create an AutoText entry and add it to a glossary document. /// </summary> private static void AppendAutoTextEntry(GlossaryDocument glossaryDoc, string name, string contents) { // Create building block and set it up as an auto text entry BuildingBlock buildingBlock = new BuildingBlock(glossaryDoc); buildingBlock.Name = name; buildingBlock.Gallery = BuildingBlockGallery.AutoText; buildingBlock.Category = "General"; buildingBlock.Behavior = BuildingBlockBehavior.Paragraph; // Add content to the building block Section section = new Section(glossaryDoc); section.AppendChild(new Body(glossaryDoc)); section.Body.AppendParagraph(contents); buildingBlock.AppendChild(section); // Add auto text entry to glossary document glossaryDoc.AppendChild(buildingBlock); }