StructuredDocumentTagRangeStart

Namespace: Aspose.Words
We found 6 examples in language CSharp for this search. You will see 31 fragments of code.

Other methods


        [Test]
        public void MultiSection()
        {
            //ExStart:MultiSectionSDT
            Document doc = new Document(MyDir + "Multi-section structured document tags.docx");

            NodeCollection tags = doc.GetChildNodes(NodeType.StructuredDocumentTagRangeStart, true);

            foreach (StructuredDocumentTagRangeStart tag in tags)
                Console.WriteLine(tag.Title);
            //ExEnd:MultiSectionSDT
        }

        [Test]
        public void RepeatingSection()
        {
            //ExStart
            //ExFor:StructuredDocumentTag.SdtType
            //ExSummary:Shows how to get the type of a structured document tag.
            Document doc = new Document(MyDir + "Structured document tags.docx");

            List<StructuredDocumentTag> sdTags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true).OfType<StructuredDocumentTag>().ToList();

            Assert.AreEqual(SdtType.RepeatingSection, sdTags[0].SdtType);
            Assert.AreEqual(SdtType.RepeatingSectionItem, sdTags[1].SdtType);
            Assert.AreEqual(SdtType.RichText, sdTags[2].SdtType);
            //ExEnd
        }

        [Test]
        public void ApplyStyle()
        {
            //ExStart
            //ExFor:StructuredDocumentTag
            //ExFor:StructuredDocumentTag.NodeType
            //ExFor:StructuredDocumentTag.Style
            //ExFor:StructuredDocumentTag.StyleName
            //ExFor:MarkupLevel
            //ExFor:SdtType
            //ExSummary:Shows how to work with styles for content control elements.
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Below are two ways to apply a style from the document to a structured document tag.
            // 1 -  Apply a style object from the document's style collection:
            Style quoteStyle = doc.Styles[StyleIdentifier.Quote];
            StructuredDocumentTag sdtPlainText = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline);
            sdtPlainText.Style = quoteStyle;

            // 2 -  Reference a style in the document by name:
            StructuredDocumentTag sdtRichText = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Inline);
            sdtRichText.StyleName = "Quote";

            builder.InsertNode(sdtPlainText);
            builder.InsertNode(sdtRichText);

            Assert.AreEqual(NodeType.StructuredDocumentTag, sdtPlainText.NodeType);

            NodeCollection tags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true);

            foreach (Node node in tags)
            {
                StructuredDocumentTag sdt = (StructuredDocumentTag)node;

                Assert.AreEqual(StyleIdentifier.Quote, sdt.Style.StyleIdentifier);
                Assert.AreEqual("Quote", sdt.StyleName);
            }
            //ExEnd
        }

        [Test]
        public void CheckBox()
        {
            //ExStart
            //ExFor:StructuredDocumentTag.#ctor(DocumentBase, SdtType, MarkupLevel)
            //ExFor:StructuredDocumentTag.Checked
            //ExSummary:Show how to create a structured document tag in the form of a check box.
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            StructuredDocumentTag sdtCheckBox = new StructuredDocumentTag(doc, SdtType.Checkbox, MarkupLevel.Inline);
            sdtCheckBox.Checked = true;

            builder.InsertNode(sdtCheckBox);

            doc.Save(ArtifactsDir + "StructuredDocumentTag.CheckBox.docx");
            //ExEnd

            doc = new Document(ArtifactsDir + "StructuredDocumentTag.CheckBox.docx");

            StructuredDocumentTag[] sdts = doc.GetChildNodes(NodeType.StructuredDocumentTag, true).OfType<StructuredDocumentTag>().ToArray();

            Assert.AreEqual(true, sdts[0].Checked);
            Assert.That(sdts[0].XmlMapping.StoreItemId, Is.Empty);
        }

#if NET462 || NETCOREAPP2_1 || JAVA // because of a Xamarin bug with CultureInfo (https://xamarin.github.io/bugzilla-archives/59/59077/bug.html)
        [Test, Category("SkipMono")]
        public void Date()
        {
            //ExStart
            //ExFor:StructuredDocumentTag.CalendarType
            //ExFor:StructuredDocumentTag.DateDisplayFormat
            //ExFor:StructuredDocumentTag.DateDisplayLocale
            //ExFor:StructuredDocumentTag.DateStorageFormat
            //ExFor:StructuredDocumentTag.FullDate
            //ExSummary:Shows how to prompt the user to enter a date with a structured document tag.
            Document doc = new Document();

            // Insert a structured document tag that prompts the user to enter a date.
            // In Microsoft Word, this element is known as a "Date picker content control".
            // When we click on the arrow on the right end of this tag in Microsoft Word,
            // we will see a pop up in the form of a clickable calendar.
            // We can use that popup to select a date that the tag will display.
            StructuredDocumentTag sdtDate = new StructuredDocumentTag(doc, SdtType.Date, MarkupLevel.Inline);

            // Display the date, according to the Saudi Arabian Arabic locale.
            sdtDate.DateDisplayLocale = CultureInfo.GetCultureInfo("ar-SA").LCID;

            // Set the format with which to display the date.
            sdtDate.DateDisplayFormat = "dd MMMM, yyyy";
            sdtDate.DateStorageFormat = SdtDateStorageFormat.DateTime;

            // Display the date according to the Hijri calendar.
            sdtDate.CalendarType = SdtCalendarType.Hijri;

            // Before the user chooses a date in Microsoft Word, the tag will display the text "Click here to enter a date.".
            // According to the tag's calendar, set the "FullDate" property to get the tag to display a default date.
            sdtDate.FullDate = new DateTime(1440, 10, 20);

            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.InsertNode(sdtDate);

            doc.Save(ArtifactsDir + "StructuredDocumentTag.Date.docx");
            //ExEnd
        }
#endif

        [Test]
        public void PlainText()
        {
            //ExStart
            //ExFor:StructuredDocumentTag.Color
            //ExFor:StructuredDocumentTag.ContentsFont
            //ExFor:StructuredDocumentTag.EndCharacterFont
            //ExFor:StructuredDocumentTag.Id
            //ExFor:StructuredDocumentTag.Level
            //ExFor:StructuredDocumentTag.Multiline
            //ExFor:StructuredDocumentTag.Tag
            //ExFor:StructuredDocumentTag.Title
            //ExFor:StructuredDocumentTag.RemoveSelfOnly
            //ExSummary:Shows how to create a structured document tag in a plain text box and modify its appearance.
            Document doc = new Document();

            // Create a structured document tag that will contain plain text.
            StructuredDocumentTag tag = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline);

            // Set the title and color of the frame that appears when you mouse over the structured document tag in Microsoft Word.
            tag.Title = "My plain text";
            tag.Color = Color.Magenta;

            // Set a tag for this structured document tag, which is obtainable
            // as an XML element named "tag", with the string below in its "@val" attribute.
            tag.Tag = "MyPlainTextSDT";

            // Every structured document tag has a random unique ID.
            Assert.That(tag.Id, Is.Positive);

            // Set the font for the text inside the structured document tag.
            tag.ContentsFont.Name = "Arial";

            // Set the font for the text at the end of the structured document tag.
            // Any text that we type in the document body after moving out of the tag with arrow keys will use this font.
            tag.EndCharacterFont.Name = "Arial Black";

            // By default, this is false and pressing enter while inside a structured document tag does nothing.
            // When set to true, our structured document tag can have multiple lines.

            // Set the "Multiline" property to "false" to only allow the contents
            // of this structured document tag to span a single line.
            // Set the "Multiline" property to "true" to allow the tag to contain multiple lines of content.
            tag.Multiline = true;

            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.InsertNode(tag);

            // Insert a clone of our structured document tag in a new paragraph.
            StructuredDocumentTag tagClone = (StructuredDocumentTag)tag.Clone(true);
            builder.InsertParagraph();
            builder.InsertNode(tagClone);

            // Use the "RemoveSelfOnly" method to remove a structured document tag, while keeping its contents in the document.
            tagClone.RemoveSelfOnly();

            doc.Save(ArtifactsDir + "StructuredDocumentTag.PlainText.docx");
            //ExEnd

            doc = new Document(ArtifactsDir + "StructuredDocumentTag.PlainText.docx");
            tag = (StructuredDocumentTag)doc.GetChild(NodeType.StructuredDocumentTag, 0, true);

            Assert.AreEqual("My plain text", tag.Title);
            Assert.AreEqual(Color.Magenta.ToArgb(), tag.Color.ToArgb());
            Assert.AreEqual("MyPlainTextSDT", tag.Tag);
            Assert.That(tag.Id, Is.Positive);
            Assert.AreEqual("Arial", tag.ContentsFont.Name);
            Assert.AreEqual("Arial Black", tag.EndCharacterFont.Name);
            Assert.True(tag.Multiline);
        }

        [TestCase(false)]
        [TestCase(true)]
        public void IsTemporary(bool isTemporary)
        {
            //ExStart
            //ExFor:StructuredDocumentTag.IsTemporary
            //ExSummary:Shows how to make single-use controls.
            Document doc = new Document();

            // Insert a plain text structured document tag,
            // which will act as a plain text form that the user may enter text into.
            StructuredDocumentTag tag = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline);

            // Set the "IsTemporary" property to "true" to make the structured document tag disappear and
            // assimilate its contents into the document after the user edits it once in Microsoft Word.
            // Set the "IsTemporary" property to "false" to allow the user to edit the contents
            // of the structured document tag any number of times.
            tag.IsTemporary = isTemporary;

            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.Write("Please enter text: ");
            builder.InsertNode(tag);

            // Insert another structured document tag in the form of a check box and set its default state to "checked".
            tag = new StructuredDocumentTag(doc, SdtType.Checkbox, MarkupLevel.Inline);
            tag.Checked = true;

            // Set the "IsTemporary" property to "true" to make the check box become a symbol
            // once the user clicks on it in Microsoft Word.
            // Set the "IsTemporary" property to "false" to allow the user to click on the check box any number of times.
            tag.IsTemporary = isTemporary;

            builder.Write("\nPlease click the check box: ");
            builder.InsertNode(tag);

            doc.Save(ArtifactsDir + "StructuredDocumentTag.IsTemporary.docx");
            //ExEnd

            doc = new Document(ArtifactsDir + "StructuredDocumentTag.IsTemporary.docx");

            Assert.AreEqual(2, 
                doc.GetChildNodes(NodeType.StructuredDocumentTag, true).Count(sdt => ((StructuredDocumentTag)sdt).IsTemporary == isTemporary));
        }

        [TestCase(false)]
        [TestCase(true)]
        public void PlaceholderBuildingBlock(bool isShowingPlaceholderText)
        {
            //ExStart
            //ExFor:StructuredDocumentTag.IsShowingPlaceholderText
            //ExFor:StructuredDocumentTag.Placeholder
            //ExFor:StructuredDocumentTag.PlaceholderName
            //ExSummary:Shows how to use a building block's contents as a custom placeholder text for a structured document tag. 
            Document doc = new Document();

            // Insert a plain text structured document tag of the "PlainText" type, which will function as a text box.
            // The contents that it will display by default are a "Click here to enter text." prompt.
            StructuredDocumentTag tag = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline);

            // We can get the tag to display the contents of a building block instead of the default text.
            // First, add a building block with contents to the glossary document.
            GlossaryDocument glossaryDoc = doc.GlossaryDocument;

            BuildingBlock substituteBlock = new BuildingBlock(glossaryDoc);
            substituteBlock.Name = "Custom Placeholder";
            substituteBlock.AppendChild(new Section(glossaryDoc));
            substituteBlock.FirstSection.AppendChild(new Body(glossaryDoc));
            substituteBlock.FirstSection.Body.AppendParagraph("Custom placeholder text.");

            glossaryDoc.AppendChild(substituteBlock);

            // Then, use the structured document tag's "PlaceholderName" property to reference that building block by name.
            tag.PlaceholderName = "Custom Placeholder";

            // If "PlaceholderName" refers to an existing block in the parent document's glossary document,
            // we will be able to verify the building block via the "Placeholder" property.
            Assert.AreEqual(substituteBlock, tag.Placeholder);

            // Set the "IsShowingPlaceholderText" property to "true" to treat the
            // structured document tag's current contents as placeholder text.
            // This means that clicking on the text box in Microsoft Word will immediately highlight all the tag's contents.
            // Set the "IsShowingPlaceholderText" property to "false" to get the
            // structured document tag to treat its contents as text that a user has already entered.
            // Clicking on this text in Microsoft Word will place the blinking cursor at the clicked location.
            tag.IsShowingPlaceholderText = isShowingPlaceholderText;

            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.InsertNode(tag);

            doc.Save(ArtifactsDir + "StructuredDocumentTag.PlaceholderBuildingBlock.docx");
            //ExEnd

            doc = new Document(ArtifactsDir + "StructuredDocumentTag.PlaceholderBuildingBlock.docx");
            tag = (StructuredDocumentTag)doc.GetChild(NodeType.StructuredDocumentTag, 0, true);
            substituteBlock = (BuildingBlock)doc.GlossaryDocument.GetChild(NodeType.BuildingBlock, 0, true);

            Assert.AreEqual("Custom Placeholder", substituteBlock.Name);
            Assert.AreEqual(isShowingPlaceholderText, tag.IsShowingPlaceholderText);
            Assert.AreEqual(substituteBlock, tag.Placeholder);
            Assert.AreEqual(substituteBlock.Name, tag.PlaceholderName);
        }

        [Test]
        public void RepeatingSection()
        {
            //ExStart
            //ExFor:StructuredDocumentTag.SdtType
            //ExSummary:Shows how to get the type of a structured document tag.
            Document doc = new Document(MyDir + "Structured document tags.docx");

            List<StructuredDocumentTag> sdTags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true).OfType<StructuredDocumentTag>().ToList();

            Assert.AreEqual(SdtType.RepeatingSection, sdTags[0].SdtType);
            Assert.AreEqual(SdtType.RepeatingSectionItem, sdTags[1].SdtType);
            Assert.AreEqual(SdtType.RichText, sdTags[2].SdtType);
            //ExEnd
        }

        [Test]
        public void ApplyStyle()
        {
            //ExStart
            //ExFor:StructuredDocumentTag
            //ExFor:StructuredDocumentTag.NodeType
            //ExFor:StructuredDocumentTag.Style
            //ExFor:StructuredDocumentTag.StyleName
            //ExFor:MarkupLevel
            //ExFor:SdtType
            //ExSummary:Shows how to work with styles for content control elements.
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            // Below are two ways to apply a style from the document to a structured document tag.
            // 1 -  Apply a style object from the document's style collection:
            Style quoteStyle = doc.Styles[StyleIdentifier.Quote];
            StructuredDocumentTag sdtPlainText = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline);
            sdtPlainText.Style = quoteStyle;

            // 2 -  Reference a style in the document by name:
            StructuredDocumentTag sdtRichText = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Inline);
            sdtRichText.StyleName = "Quote";

            builder.InsertNode(sdtPlainText);
            builder.InsertNode(sdtRichText);

            Assert.AreEqual(NodeType.StructuredDocumentTag, sdtPlainText.NodeType);

            NodeCollection tags = doc.GetChildNodes(NodeType.StructuredDocumentTag, true);

            foreach (Node node in tags)
            {
                StructuredDocumentTag sdt = (StructuredDocumentTag)node;

                Assert.AreEqual(StyleIdentifier.Quote, sdt.Style.StyleIdentifier);
                Assert.AreEqual("Quote", sdt.StyleName);
            }
            //ExEnd
        }

        [Test]
        public void CheckBox()
        {
            //ExStart
            //ExFor:StructuredDocumentTag.#ctor(DocumentBase, SdtType, MarkupLevel)
            //ExFor:StructuredDocumentTag.Checked
            //ExSummary:Show how to create a structured document tag in the form of a check box.
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            StructuredDocumentTag sdtCheckBox = new StructuredDocumentTag(doc, SdtType.Checkbox, MarkupLevel.Inline);
            sdtCheckBox.Checked = true;

            builder.InsertNode(sdtCheckBox);

            doc.Save(ArtifactsDir + "StructuredDocumentTag.CheckBox.docx");
            //ExEnd

            doc = new Document(ArtifactsDir + "StructuredDocumentTag.CheckBox.docx");

            StructuredDocumentTag[] sdts = doc.GetChildNodes(NodeType.StructuredDocumentTag, true).OfType<StructuredDocumentTag>().ToArray();

            Assert.AreEqual(true, sdts[0].Checked);
            Assert.That(sdts[0].XmlMapping.StoreItemId, Is.Empty);
        }

#if NET462 || NETCOREAPP2_1 || JAVA // because of a Xamarin bug with CultureInfo (https://xamarin.github.io/bugzilla-archives/59/59077/bug.html)
        [Test, Category("SkipMono")]
        public void Date()
        {
            //ExStart
            //ExFor:StructuredDocumentTag.CalendarType
            //ExFor:StructuredDocumentTag.DateDisplayFormat
            //ExFor:StructuredDocumentTag.DateDisplayLocale
            //ExFor:StructuredDocumentTag.DateStorageFormat
            //ExFor:StructuredDocumentTag.FullDate
            //ExSummary:Shows how to prompt the user to enter a date with a structured document tag.
            Document doc = new Document();

            // Insert a structured document tag that prompts the user to enter a date.
            // In Microsoft Word, this element is known as a "Date picker content control".
            // When we click on the arrow on the right end of this tag in Microsoft Word,
            // we will see a pop up in the form of a clickable calendar.
            // We can use that popup to select a date that the tag will display.
            StructuredDocumentTag sdtDate = new StructuredDocumentTag(doc, SdtType.Date, MarkupLevel.Inline);

            // Display the date, according to the Saudi Arabian Arabic locale.
            sdtDate.DateDisplayLocale = CultureInfo.GetCultureInfo("ar-SA").LCID;

            // Set the format with which to display the date.
            sdtDate.DateDisplayFormat = "dd MMMM, yyyy";
            sdtDate.DateStorageFormat = SdtDateStorageFormat.DateTime;

            // Display the date according to the Hijri calendar.
            sdtDate.CalendarType = SdtCalendarType.Hijri;

            // Before the user chooses a date in Microsoft Word, the tag will display the text "Click here to enter a date.".
            // According to the tag's calendar, set the "FullDate" property to get the tag to display a default date.
            sdtDate.FullDate = new DateTime(1440, 10, 20);

            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.InsertNode(sdtDate);

            doc.Save(ArtifactsDir + "StructuredDocumentTag.Date.docx");
            //ExEnd
        }
#endif

        [Test]
        public void PlainText()
        {
            //ExStart
            //ExFor:StructuredDocumentTag.Color
            //ExFor:StructuredDocumentTag.ContentsFont
            //ExFor:StructuredDocumentTag.EndCharacterFont
            //ExFor:StructuredDocumentTag.Id
            //ExFor:StructuredDocumentTag.Level
            //ExFor:StructuredDocumentTag.Multiline
            //ExFor:StructuredDocumentTag.Tag
            //ExFor:StructuredDocumentTag.Title
            //ExFor:StructuredDocumentTag.RemoveSelfOnly
            //ExSummary:Shows how to create a structured document tag in a plain text box and modify its appearance.
            Document doc = new Document();

            // Create a structured document tag that will contain plain text.
            StructuredDocumentTag tag = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline);

            // Set the title and color of the frame that appears when you mouse over the structured document tag in Microsoft Word.
            tag.Title = "My plain text";
            tag.Color = Color.Magenta;

            // Set a tag for this structured document tag, which is obtainable
            // as an XML element named "tag", with the string below in its "@val" attribute.
            tag.Tag = "MyPlainTextSDT";

            // Every structured document tag has a random unique ID.
            Assert.That(tag.Id, Is.Positive);

            // Set the font for the text inside the structured document tag.
            tag.ContentsFont.Name = "Arial";

            // Set the font for the text at the end of the structured document tag.
            // Any text that we type in the document body after moving out of the tag with arrow keys will use this font.
            tag.EndCharacterFont.Name = "Arial Black";

            // By default, this is false and pressing enter while inside a structured document tag does nothing.
            // When set to true, our structured document tag can have multiple lines.

            // Set the "Multiline" property to "false" to only allow the contents
            // of this structured document tag to span a single line.
            // Set the "Multiline" property to "true" to allow the tag to contain multiple lines of content.
            tag.Multiline = true;

            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.InsertNode(tag);

            // Insert a clone of our structured document tag in a new paragraph.
            StructuredDocumentTag tagClone = (StructuredDocumentTag)tag.Clone(true);
            builder.InsertParagraph();
            builder.InsertNode(tagClone);

            // Use the "RemoveSelfOnly" method to remove a structured document tag, while keeping its contents in the document.
            tagClone.RemoveSelfOnly();

            doc.Save(ArtifactsDir + "StructuredDocumentTag.PlainText.docx");
            //ExEnd

            doc = new Document(ArtifactsDir + "StructuredDocumentTag.PlainText.docx");
            tag = (StructuredDocumentTag)doc.GetChild(NodeType.StructuredDocumentTag, 0, true);

            Assert.AreEqual("My plain text", tag.Title);
            Assert.AreEqual(Color.Magenta.ToArgb(), tag.Color.ToArgb());
            Assert.AreEqual("MyPlainTextSDT", tag.Tag);
            Assert.That(tag.Id, Is.Positive);
            Assert.AreEqual("Arial", tag.ContentsFont.Name);
            Assert.AreEqual("Arial Black", tag.EndCharacterFont.Name);
            Assert.True(tag.Multiline);
        }

        [TestCase(false)]
        [TestCase(true)]
        public void IsTemporary(bool isTemporary)
        {
            //ExStart
            //ExFor:StructuredDocumentTag.IsTemporary
            //ExSummary:Shows how to make single-use controls.
            Document doc = new Document();

            // Insert a plain text structured document tag,
            // which will act as a plain text form that the user may enter text into.
            StructuredDocumentTag tag = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline);

            // Set the "IsTemporary" property to "true" to make the structured document tag disappear and
            // assimilate its contents into the document after the user edits it once in Microsoft Word.
            // Set the "IsTemporary" property to "false" to allow the user to edit the contents
            // of the structured document tag any number of times.
            tag.IsTemporary = isTemporary;

            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.Write("Please enter text: ");
            builder.InsertNode(tag);

            // Insert another structured document tag in the form of a check box and set its default state to "checked".
            tag = new StructuredDocumentTag(doc, SdtType.Checkbox, MarkupLevel.Inline);
            tag.Checked = true;

            // Set the "IsTemporary" property to "true" to make the check box become a symbol
            // once the user clicks on it in Microsoft Word.
            // Set the "IsTemporary" property to "false" to allow the user to click on the check box any number of times.
            tag.IsTemporary = isTemporary;

            builder.Write("\nPlease click the check box: ");
            builder.InsertNode(tag);

            doc.Save(ArtifactsDir + "StructuredDocumentTag.IsTemporary.docx");
            //ExEnd

            doc = new Document(ArtifactsDir + "StructuredDocumentTag.IsTemporary.docx");

            Assert.AreEqual(2, 
                doc.GetChildNodes(NodeType.StructuredDocumentTag, true).Count(sdt => ((StructuredDocumentTag)sdt).IsTemporary == isTemporary));
        }

        [TestCase(false)]
        [TestCase(true)]
        public void PlaceholderBuildingBlock(bool isShowingPlaceholderText)
        {
            //ExStart
            //ExFor:StructuredDocumentTag.IsShowingPlaceholderText
            //ExFor:StructuredDocumentTag.Placeholder
            //ExFor:StructuredDocumentTag.PlaceholderName
            //ExSummary:Shows how to use a building block's contents as a custom placeholder text for a structured document tag. 
            Document doc = new Document();

            // Insert a plain text structured document tag of the "PlainText" type, which will function as a text box.
            // The contents that it will display by default are a "Click here to enter text." prompt.
            StructuredDocumentTag tag = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Inline);

            // We can get the tag to display the contents of a building block instead of the default text.
            // First, add a building block with contents to the glossary document.
            GlossaryDocument glossaryDoc = doc.GlossaryDocument;

            BuildingBlock substituteBlock = new BuildingBlock(glossaryDoc);
            substituteBlock.Name = "Custom Placeholder";
            substituteBlock.AppendChild(new Section(glossaryDoc));
            substituteBlock.FirstSection.AppendChild(new Body(glossaryDoc));
            substituteBlock.FirstSection.Body.AppendParagraph("Custom placeholder text.");

            glossaryDoc.AppendChild(substituteBlock);

            // Then, use the structured document tag's "PlaceholderName" property to reference that building block by name.
            tag.PlaceholderName = "Custom Placeholder";

            // If "PlaceholderName" refers to an existing block in the parent document's glossary document,
            // we will be able to verify the building block via the "Placeholder" property.
            Assert.AreEqual(substituteBlock, tag.Placeholder);

            // Set the "IsShowingPlaceholderText" property to "true" to treat the
            // structured document tag's current contents as placeholder text.
            // This means that clicking on the text box in Microsoft Word will immediately highlight all the tag's contents.
            // Set the "IsShowingPlaceholderText" property to "false" to get the
            // structured document tag to treat its contents as text that a user has already entered.
            // Clicking on this text in Microsoft Word will place the blinking cursor at the clicked location.
            tag.IsShowingPlaceholderText = isShowingPlaceholderText;

            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.InsertNode(tag);

            doc.Save(ArtifactsDir + "StructuredDocumentTag.PlaceholderBuildingBlock.docx");
            //ExEnd

            doc = new Document(ArtifactsDir + "StructuredDocumentTag.PlaceholderBuildingBlock.docx");
            tag = (StructuredDocumentTag)doc.GetChild(NodeType.StructuredDocumentTag, 0, true);
            substituteBlock = (BuildingBlock)doc.GlossaryDocument.GetChild(NodeType.BuildingBlock, 0, true);

            Assert.AreEqual("Custom Placeholder", substituteBlock.Name);
            Assert.AreEqual(isShowingPlaceholderText, tag.IsShowingPlaceholderText);
            Assert.AreEqual(substituteBlock, tag.Placeholder);
            Assert.AreEqual(substituteBlock.Name, tag.PlaceholderName);
        }

        [Test]
        public void CheckBoxTypeContentControl()
        {
            //ExStart:CheckBoxTypeContentControl
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            StructuredDocumentTag sdtCheckBox = new StructuredDocumentTag(doc, SdtType.Checkbox, MarkupLevel.Inline);
            builder.InsertNode(sdtCheckBox);
            
            doc.Save(ArtifactsDir + "WorkingWithSdt.CheckBoxTypeContentControl.docx", SaveFormat.Docx);
            //ExEnd:CheckBoxTypeContentControl
        }

        [Test]
        public void CurrentStateOfCheckBox()
        {
            //ExStart:SetCurrentStateOfCheckBox
            Document doc = new Document(MyDir + "Structured document tags.docx");
            
            // Get the first content control from the document.
            StructuredDocumentTag sdtCheckBox =
                (StructuredDocumentTag) doc.GetChild(NodeType.StructuredDocumentTag, 0, true);

            if (sdtCheckBox.SdtType == SdtType.Checkbox)
                sdtCheckBox.Checked = true;

            doc.Save(ArtifactsDir + "WorkingWithSdt.CurrentStateOfCheckBox.docx");
            //ExEnd:SetCurrentStateOfCheckBox
        }

        [Test]
        public void ModifyContentControls()
        {
            //ExStart:ModifyContentControls
            Document doc = new Document(MyDir + "Structured document tags.docx");

            foreach (StructuredDocumentTag sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true))
            {
                switch (sdt.SdtType)
                {
                    case SdtType.PlainText:
                    {
                        sdt.RemoveAllChildren();
                        Paragraph para = sdt.AppendChild(new Paragraph(doc)) as Paragraph;
                        Run run = new Run(doc, "new text goes here");
                        para.AppendChild(run);
                        break;
                    }
                    case SdtType.DropDownList:
                    {
                        SdtListItem secondItem = sdt.ListItems[2];
                        sdt.ListItems.SelectedValue = secondItem;
                        break;
                    }
                    case SdtType.Picture:
                    {
                        Shape shape = (Shape) sdt.GetChild(NodeType.Shape, 0, true);
                        if (shape.HasImage)
                        {
                            shape.ImageData.SetImage(ImagesDir + "Watermark.png");
                        }

                        break;
                    }
                }
            }
            
            doc.Save(ArtifactsDir + "WorkingWithSdt.ModifyContentControls.docx");
            //ExEnd:ModifyContentControls
        }

        [Test]
        public void ComboBoxContentControl()
        {
            //ExStart:ComboBoxContentControl
            Document doc = new Document();

            StructuredDocumentTag sdt = new StructuredDocumentTag(doc, SdtType.ComboBox, MarkupLevel.Block);
            sdt.ListItems.Add(new SdtListItem("Choose an item", "-1"));
            sdt.ListItems.Add(new SdtListItem("Item 1", "1"));
            sdt.ListItems.Add(new SdtListItem("Item 2", "2"));
            doc.FirstSection.Body.AppendChild(sdt);

            doc.Save(ArtifactsDir + "WorkingWithSdt.ComboBoxContentControl.docx");
            //ExEnd:ComboBoxContentControl
        }

        [Test]
        public void RichTextBoxContentControl()
        {
            //ExStart:RichTextBoxContentControl
            Document doc = new Document();

            StructuredDocumentTag sdtRichText = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Block);

            Paragraph para = new Paragraph(doc);
            Run run = new Run(doc);
            run.Text = "Hello World";
            run.Font.Color = Color.Green;
            para.Runs.Add(run);
            sdtRichText.ChildNodes.Add(para);
            doc.FirstSection.Body.AppendChild(sdtRichText);

            doc.Save(ArtifactsDir + "WorkingWithSdt.RichTextBoxContentControl.docx");
            //ExEnd:RichTextBoxContentControl
        }

        [Test]
        public void SetContentControlColor()
        {
            //ExStart:SetContentControlColor
            Document doc = new Document(MyDir + "Structured document tags.docx");

            StructuredDocumentTag sdt = (StructuredDocumentTag) doc.GetChild(NodeType.StructuredDocumentTag, 0, true);
            sdt.Color = Color.Red;

            doc.Save(ArtifactsDir + "WorkingWithSdt.SetContentControlColor.docx");
            //ExEnd:SetContentControlColor
        }

        [Test]
        public void CheckBoxTypeContentControl()
        {
            //ExStart:CheckBoxTypeContentControl
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            StructuredDocumentTag sdtCheckBox = new StructuredDocumentTag(doc, SdtType.Checkbox, MarkupLevel.Inline);
            builder.InsertNode(sdtCheckBox);
            
            doc.Save(ArtifactsDir + "WorkingWithSdt.CheckBoxTypeContentControl.docx", SaveFormat.Docx);
            //ExEnd:CheckBoxTypeContentControl
        }

        [Test]
        public void CurrentStateOfCheckBox()
        {
            //ExStart:SetCurrentStateOfCheckBox
            Document doc = new Document(MyDir + "Structured document tags.docx");
            
            // Get the first content control from the document.
            StructuredDocumentTag sdtCheckBox =
                (StructuredDocumentTag) doc.GetChild(NodeType.StructuredDocumentTag, 0, true);

            if (sdtCheckBox.SdtType == SdtType.Checkbox)
                sdtCheckBox.Checked = true;

            doc.Save(ArtifactsDir + "WorkingWithSdt.CurrentStateOfCheckBox.docx");
            //ExEnd:SetCurrentStateOfCheckBox
        }

        [Test]
        public void ModifyContentControls()
        {
            //ExStart:ModifyContentControls
            Document doc = new Document(MyDir + "Structured document tags.docx");

            foreach (StructuredDocumentTag sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true))
            {
                switch (sdt.SdtType)
                {
                    case SdtType.PlainText:
                    {
                        sdt.RemoveAllChildren();
                        Paragraph para = sdt.AppendChild(new Paragraph(doc)) as Paragraph;
                        Run run = new Run(doc, "new text goes here");
                        para.AppendChild(run);
                        break;
                    }
                    case SdtType.DropDownList:
                    {
                        SdtListItem secondItem = sdt.ListItems[2];
                        sdt.ListItems.SelectedValue = secondItem;
                        break;
                    }
                    case SdtType.Picture:
                    {
                        Shape shape = (Shape) sdt.GetChild(NodeType.Shape, 0, true);
                        if (shape.HasImage)
                        {
                            shape.ImageData.SetImage(ImagesDir + "Watermark.png");
                        }

                        break;
                    }
                }
            }
            
            doc.Save(ArtifactsDir + "WorkingWithSdt.ModifyContentControls.docx");
            //ExEnd:ModifyContentControls
        }

        [Test]
        public void ComboBoxContentControl()
        {
            //ExStart:ComboBoxContentControl
            Document doc = new Document();

            StructuredDocumentTag sdt = new StructuredDocumentTag(doc, SdtType.ComboBox, MarkupLevel.Block);
            sdt.ListItems.Add(new SdtListItem("Choose an item", "-1"));
            sdt.ListItems.Add(new SdtListItem("Item 1", "1"));
            sdt.ListItems.Add(new SdtListItem("Item 2", "2"));
            doc.FirstSection.Body.AppendChild(sdt);

            doc.Save(ArtifactsDir + "WorkingWithSdt.ComboBoxContentControl.docx");
            //ExEnd:ComboBoxContentControl
        }

        [Test]
        public void RichTextBoxContentControl()
        {
            //ExStart:RichTextBoxContentControl
            Document doc = new Document();

            StructuredDocumentTag sdtRichText = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Block);

            Paragraph para = new Paragraph(doc);
            Run run = new Run(doc);
            run.Text = "Hello World";
            run.Font.Color = Color.Green;
            para.Runs.Add(run);
            sdtRichText.ChildNodes.Add(para);
            doc.FirstSection.Body.AppendChild(sdtRichText);

            doc.Save(ArtifactsDir + "WorkingWithSdt.RichTextBoxContentControl.docx");
            //ExEnd:RichTextBoxContentControl
        }

        [Test]
        public void SetContentControlColor()
        {
            //ExStart:SetContentControlColor
            Document doc = new Document(MyDir + "Structured document tags.docx");

            StructuredDocumentTag sdt = (StructuredDocumentTag) doc.GetChild(NodeType.StructuredDocumentTag, 0, true);
            sdt.Color = Color.Red;

            doc.Save(ArtifactsDir + "WorkingWithSdt.SetContentControlColor.docx");
            //ExEnd:SetContentControlColor
        }

        [Test]
        public void CheckBoxTypeContentControl()
        {
            //ExStart:CheckBoxTypeContentControl
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);

            StructuredDocumentTag sdtCheckBox = new StructuredDocumentTag(doc, SdtType.Checkbox, MarkupLevel.Inline);
            builder.InsertNode(sdtCheckBox);
            
            doc.Save(ArtifactsDir + "WorkingWithSdt.CheckBoxTypeContentControl.docx", SaveFormat.Docx);
            //ExEnd:CheckBoxTypeContentControl
        }

        [Test]
        public void CurrentStateOfCheckBox()
        {
            //ExStart:SetCurrentStateOfCheckBox
            Document doc = new Document(MyDir + "Structured document tags.docx");
            
            // Get the first content control from the document.
            StructuredDocumentTag sdtCheckBox =
                (StructuredDocumentTag) doc.GetChild(NodeType.StructuredDocumentTag, 0, true);

            if (sdtCheckBox.SdtType == SdtType.Checkbox)
                sdtCheckBox.Checked = true;

            doc.Save(ArtifactsDir + "WorkingWithSdt.CurrentStateOfCheckBox.docx");
            //ExEnd:SetCurrentStateOfCheckBox
        }

        [Test]
        public void ModifyContentControls()
        {
            //ExStart:ModifyContentControls
            Document doc = new Document(MyDir + "Structured document tags.docx");

            foreach (StructuredDocumentTag sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true))
            {
                switch (sdt.SdtType)
                {
                    case SdtType.PlainText:
                    {
                        sdt.RemoveAllChildren();
                        Paragraph para = sdt.AppendChild(new Paragraph(doc)) as Paragraph;
                        Run run = new Run(doc, "new text goes here");
                        para.AppendChild(run);
                        break;
                    }
                    case SdtType.DropDownList:
                    {
                        SdtListItem secondItem = sdt.ListItems[2];
                        sdt.ListItems.SelectedValue = secondItem;
                        break;
                    }
                    case SdtType.Picture:
                    {
                        Shape shape = (Shape) sdt.GetChild(NodeType.Shape, 0, true);
                        if (shape.HasImage)
                        {
                            shape.ImageData.SetImage(ImagesDir + "Watermark.png");
                        }

                        break;
                    }
                }
            }
            
            doc.Save(ArtifactsDir + "WorkingWithSdt.ModifyContentControls.docx");
            //ExEnd:ModifyContentControls
        }

        [Test]
        public void ComboBoxContentControl()
        {
            //ExStart:ComboBoxContentControl
            Document doc = new Document();

            StructuredDocumentTag sdt = new StructuredDocumentTag(doc, SdtType.ComboBox, MarkupLevel.Block);
            sdt.ListItems.Add(new SdtListItem("Choose an item", "-1"));
            sdt.ListItems.Add(new SdtListItem("Item 1", "1"));
            sdt.ListItems.Add(new SdtListItem("Item 2", "2"));
            doc.FirstSection.Body.AppendChild(sdt);

            doc.Save(ArtifactsDir + "WorkingWithSdt.ComboBoxContentControl.docx");
            //ExEnd:ComboBoxContentControl
        }

        [Test]
        public void RichTextBoxContentControl()
        {
            //ExStart:RichTextBoxContentControl
            Document doc = new Document();

            StructuredDocumentTag sdtRichText = new StructuredDocumentTag(doc, SdtType.RichText, MarkupLevel.Block);

            Paragraph para = new Paragraph(doc);
            Run run = new Run(doc);
            run.Text = "Hello World";
            run.Font.Color = Color.Green;
            para.Runs.Add(run);
            sdtRichText.ChildNodes.Add(para);
            doc.FirstSection.Body.AppendChild(sdtRichText);

            doc.Save(ArtifactsDir + "WorkingWithSdt.RichTextBoxContentControl.docx");
            //ExEnd:RichTextBoxContentControl
        }

        [Test]
        public void SetContentControlColor()
        {
            //ExStart:SetContentControlColor
            Document doc = new Document(MyDir + "Structured document tags.docx");

            StructuredDocumentTag sdt = (StructuredDocumentTag) doc.GetChild(NodeType.StructuredDocumentTag, 0, true);
            sdt.Color = Color.Red;

            doc.Save(ArtifactsDir + "WorkingWithSdt.SetContentControlColor.docx");
            //ExEnd:SetContentControlColor
        }

Aspose.Words.Markup.StructuredDocumentTagRangeStart : IEnumerable

Constructors :

public StructuredDocumentTagRangeStart(DocumentBase doc = , SdtType type = )

Methods :

public NodeCollection GetChildNodes(NodeType nodeType = , Boolean isDeep = )
public NodeType get_NodeType()
public NodeCollection get_ChildNodes()
public Node get_LastChild()
public MarkupLevel get_Level()
public SdtType get_SdtType()
public Color get_Color()
public Void set_Color(Color value = )
public Int32 get_Id()
public Boolean get_LockContentControl()
public Void set_LockContentControl(Boolean value = )
public Boolean get_LockContents()
public Void set_LockContents(Boolean value = )
public Boolean get_IsShowingPlaceholderText()
public Void set_IsShowingPlaceholderText(Boolean value = )
public BuildingBlock get_Placeholder()
public String get_PlaceholderName()
public Void set_PlaceholderName(String value = )
public String get_Tag()
public Void set_Tag(String value = )
public String get_Title()
public Void set_Title(String value = )
public String get_WordOpenXML()
public XmlMapping get_XmlMapping()
public Boolean Accept(DocumentVisitor visitor = )
public StructuredDocumentTagRangeEnd get_RangeEnd()
public IEnumerator<Node> GetEnumerator()
public Node AppendChild(Node newChild = )
public Void RemoveAllChildren()
public Void RemoveSelfOnly()
public CompositeNode get_ParentNode()
public DocumentBase get_Document()
public Node get_PreviousSibling()
public Node get_NextSibling()
public Boolean get_IsComposite()
public Range get_Range()
public Node Clone(Boolean isCloneChildren = )
public String GetText()
public CompositeNode GetAncestor(Type ancestorType = )
public CompositeNode GetAncestor(NodeType ancestorType = )
public Void Remove()
public Node NextPreOrder(Node rootNode = )
public Node PreviousPreOrder(Node rootNode = )
public String ToString(SaveFormat saveFormat = )
public String ToString(SaveOptions saveOptions = )
public Int32 get_CustomNodeId()
public Void set_CustomNodeId(Int32 value = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

Other methods