Click here to Skip to main content
15,880,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

Today i realized that when i have more than 255 lines and i apply numbering bullets RichTextBox keep giving me number 255 after line 254 see the picture i insert.

Edit: I use WinForms
Edit 2: I put part of my code that relate to set ordered list in RichTextBox

[^]Click to see the screenshot[^]

Is this a limitation of RichTextBox or i have to do something to fix it?

Thank you

What I have tried:

I don't know what to do. I don't know what the cause may be to start fixing from it.
I have numbering bullets from SendMessage function by PARAFORMAT2

Part of my code:

C#
#region PARAFORMAT2
        [StructLayout(LayoutKind.Sequential)]
        private class PARAFORMAT2
        {
            public int cbSize;
            public int dwMask;
            public short wNumbering;
            public short wReserved;
            public int dxStartIndent;
            public int dxRightIndent;
            public int dxOffset;
            public short wAlignment;
            public short cTabCount;
            [MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x20)]
            public int[] rgxTabs;

            public int dySpaceBefore;     // Vertical spacing before para
            public int dySpaceAfter;     // Vertical spacing after para
            public int dyLineSpacing;     // Line spacing depending on Rule
            public short sStyle;         // Style handle
            public byte bLineSpacingRule;     // Rule for line spacing (see tom.doc)
            public byte bOutlineLevel;     // Outline Level
            public short wShadingWeight;     // Shading in hundredths of a per cent
            public short wShadingStyle;     // Byte 0: style, nib 2: cfpat, 3: cbpat
            public short wNumberingStart;     // Starting value for numbering
            public short wNumberingStyle;     // Alignment, Roman/Arabic, (), ), ., etc.
            public short wNumberingTab;     // Space bet 1st indent and 1st-line text
            public short wBorderSpace;     // Border-text spaces (nbl/bdr in pts)
            public short wBorderWidth;     // Pen widths (nbl/bdr in half twips)
            public short wBorders;         // Border styles (nibble/border)

            public PARAFORMAT2()
            {
                this.cbSize = Marshal.SizeOf(typeof(PARAFORMAT2));
            }
        }
        #endregion


C#
public enum Paraformat2Numbering
        {
            zero = 0,
            Normal = 1,             //No paragraph numbering or bullets.
            ArabicNumbers = 2,      //Uses Arabic numbers (1, 2, 3, ...). 
            LowerCaseLetter = 3,    //Uses lowercase letters (a, b, c, ...). 
            UpperCaseLetter = 4,    //Uses uppercase letters (A, B, C, ...). 
            LowerCaseRoman = 5,     //Uses lowercase Roman numerals (i, ii, iii, ...). 
            UpperCaseRoman = 6      //Uses uppercase Roman numerals (I, II, III, ...). 
        }


C#
public enum Paraformat2NumberingStyle
        {
            RightParenthesis = 0x000,//Follows the number with a right parenthesis.
            DoubleParenthesis = 0x100,//Encloses the number in parentheses.
            Period = 0x200,//Follows the number with a period.
            Plain = 0x300,//Displays only the number.
            zero = 0x400//Continues a numbered list without applying the next number or bullet. 
        }


C#
public bool SelectionOrderList
        {
            get
            {
                return (
                       (GetSelectionParaformat2wNumbering() == Paraformat2Numbering.ArabicNumbers) &&
                       (GetSelectionParaformat2wNumberingStyle() == Paraformat2NumberingStyle.Period)
                       );

            }
            set
            {
                bOrder = value;

                if (value == true)
                    SetSelectionParaFormat2(Paraformat2NumberingStyle.Period, Paraformat2Numbering.ArabicNumbers);
                else
                    RemoveSelectionParaFormat2();
            }
        }


SetSelectionParaFotrmat2 method

C#
public void SetSelectionParaFormat2(Paraformat2NumberingStyle style, Paraformat2Numbering Number)
        {
            PARAFORMAT2 p = new PARAFORMAT2();
            p.dwMask = (int)(PFM_NUMBERING | PFM_OFFSET | PFM_NUMBERINGSTART | PFM_NUMBERINGSTYLE | PFM_NUMBERINGTAB);

            p.wNumbering = (short)Number;
            //p.dxOffset = BulletIndent;
            p.wNumberingStyle = (short)style;
            p.wNumberingStart = 1;
            p.wNumberingTab = 500;

            SendMessage(richTextBox.Handle, EM_SETPARAFORMAT, 0, p);
        }


I set them by this

C#
public bool SelectionOrderList
        {
            get
            {
                richTextBoxBulletClass r = new richTextBoxBulletClass();
                r.richTextBox = note_txt;
                return r.SelectionOrderList;
            }
            set
            {
                richTextBoxBulletClass r = new richTextBoxBulletClass();
                r.richTextBox = note_txt;
                r.SelectionOrderList = value;
            }
        }


Hope that helps
Posted
Updated 18-Feb-17 0:06am
v3
Comments
Valery Possoz 17-Feb-17 14:38pm    
WPF or Winform?
Karthik_Mahalingam 17-Feb-17 23:43pm    
OP has tagged "windows"
Richard Deeming 18-Feb-17 9:05am    
"Windows" could mean Windows Forms, WPF, or something else. :)

(The OP has updated the question to clarify.)
Karthik_Mahalingam 18-Feb-17 9:10am    
oh sorry Richard, at a glimpse i read as "web"..
:)

1 solution

The standard RichTextBox does not support numbered bullets - so if you got the code from an article, then there is a "Add a Comment or Question" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.

Otherwise, we would need to see the actual code fragments you used to set the numbered bullets in the RTF of the control.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900