Aspose.Words.Examples.CSharp.Programming_Documents.Working_With_Document.UpdateContentControls.SetCurrentStateOfCheckBox C# (CSharp) Method

SetCurrentStateOfCheckBox() public static method

public static SetCurrentStateOfCheckBox ( string dataDir ) : void
dataDir string
return void
        public static void SetCurrentStateOfCheckBox(string dataDir)
        {
            // ExStart:SetCurrentStateOfCheckBox
            // Open an existing document
            Document doc = new Document(dataDir + "CheckBoxTypeContentControl.docx");

            DocumentBuilder builder = new DocumentBuilder(doc);
            // Get the first content control from the document
            StructuredDocumentTag SdtCheckBox = (StructuredDocumentTag)doc.GetChild(NodeType.StructuredDocumentTag, 0, true);

            // StructuredDocumentTag.Checked property gets/sets current state of the Checkbox SDT
            if (SdtCheckBox.SdtType == SdtType.Checkbox)
                SdtCheckBox.Checked = true;

            dataDir = dataDir + "SetCurrentStateOfCheckBox_out.docx";
            doc.Save(dataDir);
            // ExEnd:SetCurrentStateOfCheckBox
            Console.WriteLine("\nCurrent state fo checkbox setup successfully.\nFile saved at " + dataDir);
        }
        public static void ModifyContentControls(string dataDir)