insert line number in to richtextbox in c#

Home Forums General Programming C# insert line number in to richtextbox in c#

Tagged: ,

This topic contains 0 replies, has 1 voice, and was last updated by  Hirendra Sisodiya 6 years, 2 months ago.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #4123

    if you want to insert line numbers into richtextbox control. Suppose you have a richtextbox control with the some text of lines and you want to add line number as prefix (1,2,3…), you can use the following code of lines:

    string[] arrStr = richTextBox1.Lines;
    for (int i = 0; i < arrStr.Length ; i++)
     {
       arrStr[i] = i+1 + ". " + arrStr[i];
     }
    richTextBox1.Lines = arrStr;
    

    Line numbers in Rich text box

    Try the code..
    Thanks

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.