private void comboBoxEdit1_Left(object sender, EventArgs e)
        {
            #region #setlistlevel
            // Create a list item from the selected paragraph. A list pattern with index 0 is used.
            // The list level is specified by selecting an item in a combo box.
            Document doc = richEditControl1.Document;

            if (doc.Selection != null)
            {
                int listLevel = comboBoxEdit1.SelectedIndex - 1;
                doc.BeginUpdate();
                ReadOnlyParagraphCollection paragraphs = doc.Paragraphs.Get(doc.Selection);
                foreach (Paragraph pgf in paragraphs)
                {
                    // If 'None" is selected in the list level combo, remove the paragraph from the list.
                    if (listLevel == -1)
                    {
                        pgf.ListIndex = -1;
                    }
                    // Otherwise specify the list pattern and the list level.
                    else
                    {
                        pgf.ListIndex = 0;
                        pgf.ListLevel = listLevel;
                    }
                }
                doc.EndUpdate();
            }
            #endregion #setlistlevel
        }
 private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
 {
     #region #setlistlevel
     // Create a bulleted list item from the selected paragraph. A list pattern with index 0 is used.
     // The list level is specified by selecting an item in a combo box.
     Document doc = richEditControl1.Document;
     if (doc.Selection != null)
     {
         int listLevel = comboBoxEdit1.SelectedIndex;
         doc.BeginUpdate();
         ReadOnlyParagraphCollection paragraphs = doc.Paragraphs.Get(doc.Selection);
         foreach (Paragraph pgf in paragraphs)
         {
             pgf.ListIndex = 0;
             pgf.ListLevel = listLevel;
         }
         doc.EndUpdate();
     }
     #endregion #setlistlevel
 }
        private void ApplyNextListToSelection(Document document)
        {
            document.BeginUpdate();

            ReadOnlyParagraphCollection paragraphs = document.Paragraphs.Get(document.Selection);

            for (int i = 0; i < paragraphs.Count; i++)
            {
                int       currentAbstractIndex = GetParagraphAbstractIndex(document, paragraphs[i]);
                Paragraph previousParagraph    = null;

                if (i > 0)
                {
                    previousParagraph = paragraphs[i - 1];
                }

                paragraphs[i].ListIndex = GetNextListIndex(document, currentAbstractIndex, previousParagraph);
            }

            document.EndUpdate();
        }