Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6974127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:11:48+00:00 2026-05-27T17:11:48+00:00

I have to add line numbering to my application (C++/CLI – .net2.0) which is

  • 0

I have to add line numbering to my application (C++/CLI – .net2.0) which is a code editor for specialized programming language.

The problem is in a performance of my solution. I did it like this, for every textChanged event of my _rtbCode control this function is fired:

void DocumentElement::SetupLineNumbersCount() {
    StringBuilder ^builder = gcnew StringBuilder();
    if(_tbLineNumbers->Lines->Length > _rtbCode->Lines->Length) {
        for(int i = 0; i <= _rtbCode->Lines->Length;) {
            if(i != 0) builder->Append("\r\n");
            builder->Append(++ i);
            builder->Append(".");
        }
        _tbLineNumbers->Text = builder->ToString();
    }
    else if(_tbLineNumbers->Lines->Length < _rtbCode->Lines->Length) {
        builder->Append(_tbLineNumbers->Text);
        for(int i = _tbLineNumbers->Lines->Length; i < _rtbCode->Lines->Length;) {
            builder->Append("\r\n");
            builder->Append(++ i);
            builder->Append(".");
        }
        _tbLineNumbers->Text = builder->ToString();
    }
}

Where _tbLineNumbers is a TextBox where line numbers are put.
This is soooo slow (I’ve compared this with some other code editors). I tried to paste couple lines (around 10000) and I have huge delay of reaction.

(I already checked How to print line numbers for textbox in c#)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:11:49+00:00Added an answer on May 27, 2026 at 5:11 pm

    Would it be better to update the line number TextBox on Scroll/Resize events of the code TextBox?

    This way, you’d only need to care about the visible set of lines, and typing in the code window wouldn’t require a refresh of the line numbers.

    GetFirstVisibleLineIndex

    GetLastVisibleLineIndex

    These may help you out too!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a computed column created with the following line: alter table tbPedidos add
Ext-js Chart, I have a line graph, and I wish to add a single
I have Excel add-in which I add so many class modules that it is
I have to add some enum options to a database table. The problem being,
Using C++, I want to generate a file in which I have to add
I have an ordered list which uses large Georgia for the numbering and smaller
I have a standard XML document, which looks like a 'tree'. I add some
I have this code: List<string> lineList = new List<string>(); foreach (var line in theFinalList)
I have to add a coupon table to my db. There are 3 types
I have to add either an embed tag for Firefox or an object tag

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.