//// This code is part of Document Solutions for Word demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.Globalization;usingGrapeCity.Documents.Word;usingGrapeCity.Documents.Word.Fields; namespaceDsWordWeb.Demos{// This sample shows how to add an AUTONUM (Automatic Numbering) field to a Word document,// and specify its options.publicclassAutoNumFieldOpts {publicGcWordDocumentCreateDocx() {GcWordDocument doc = new(); // create options to insert AUTONUM fields in the documentAutoNumFieldOptions options = new(doc); // create a structure of paragraphs with different outline level// and insert AUTONUM field to the beginning of each paragraph// to automatically number themParagraph p = doc.Body.AddParagraph("Heading 1", doc.Styles[BuiltInStyleId.Heading1]); p.GetRange().ComplexFields.Insert(options, InsertLocation.Start); p = doc.Body.AddParagraph("Heading 2", doc.Styles[BuiltInStyleId.Heading2]); p.GetRange().ComplexFields.Insert(options, InsertLocation.Start); p = doc.Body.AddParagraph("Heading 2", doc.Styles[BuiltInStyleId.Heading2]); p.GetRange().ComplexFields.Insert(options, InsertLocation.Start); p = doc.Body.AddParagraph("Heading 3", doc.Styles[BuiltInStyleId.Heading3]); p.GetRange().ComplexFields.Insert(options, InsertLocation.Start); p = doc.Body.AddParagraph("Heading 3", doc.Styles[BuiltInStyleId.Heading3]); p.GetRange().ComplexFields.Insert(options, InsertLocation.Start); p = doc.Body.AddParagraph("Heading 1", doc.Styles[BuiltInStyleId.Heading1]); p.GetRange().ComplexFields.Insert(options, InsertLocation.Start); p = doc.Body.AddParagraph("Heading 2", doc.Styles[BuiltInStyleId.Heading2]); p.GetRange().ComplexFields.Insert(options, InsertLocation.Start); // Update fields using a specific culture: doc.UpdateFields(newGrapeCity.Documents.Word.Layout.WordLayoutSettings() { FontCollection = Util.FontCollection, Culture = CultureInfo.GetCultureInfo("en-US") }); // Done:return doc; } }}