Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How do I lock the indent feature so that any reference needing a second (or third or fourth etc...) line of text is indented underneath the first? Where a paragraph indents the first line, and all following lines are left centered, this is the exact opposite.

share|improve this question

migrated from stackoverflow.com Dec 11 '12 at 9:17

This question came from our site for professional and enthusiast programmers.

1 Answer 1

You can set the first paragraph as a heading and other paragraphs as body.

C# Code Here:

        //Create Document
        Document document = new Document();
        Section section = document.AddSection();
        Paragraph paragraph
            = section.Paragraphs.Count > 0 ? section.Paragraphs[0] : section.AddParagraph();

        //Heading 1
        paragraph = section.AddParagraph();
        paragraph.AppendText(BuiltinStyle.Heading1.ToString());
        paragraph.ApplyStyle(BuiltinStyle.Heading1);
        paragraph.ListFormat.ApplyNumberedStyle();

        //Heading 2
        paragraph = section.AddParagraph();
        paragraph.AppendText(BuiltinStyle.Heading2.ToString());
        paragraph.ApplyStyle(BuiltinStyle.Heading2);

        //Number Format(list) for Headings
        ListStyle listSty2 = new ListStyle(document, ListType.Numbered);
        foreach (ListLevel listLev in listSty2.Levels)
        {
            listLev.UsePrevLevelPattern = true;
            listLev.NumberPrefix = “1.”;
        }

        listSty2.Name = “MyStyle2″;
        document.ListStyles.Add(listSty2);
        paragraph.ListFormat.ApplyStyle(listSty2.Name);      

        ListStyle listSty3 = new ListStyle(document, ListType.Numbered);
        foreach (ListLevel listLev in listSty3.Levels)
        {
            listLev.UsePrevLevelPattern = true;
            listLev.NumberPrefix = “1.1.”;
        }
        listSty3.Name = “MyStyle3″;
        document.ListStyles.Add(listSty3);

        //Heading 3
        for (int i = 0; i < 4; i++)
        {
            paragraph = section.AddParagraph();

            //Append Text
            paragraph.AppendText(“Heading3″);

            //Apply Style
            paragraph.ApplyStyle(BuiltinStyle.Heading3);
            paragraph.ListFormat.ApplyStyle(listSty3.Name);
        }

I use a .NET Word component.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.