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 1058795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:04:37+00:00 2026-05-16T18:04:37+00:00

I was programming a small notepad like app with some extra functionalities. I am

  • 0

I was programming a small notepad like app with some extra functionalities.

I am using a rich textbox as the main area. My question is while performing operations on the contents of the textbox, like code formatting, highlighting, etc which might require reading each character and replacing wherever necessary. Moving back across text indexes occasionally.
What would be more efficient for an autoformat button:

  • Directly reading on the textbox.text
    property. Appending the formated
    string chars into a stringbuilder &
    finally back to the textbox (using
    toString function).

    or

  • Copying the entire content into a
    string, reading character by
    character into a new
    stringbuilder…..and as above.
    Doesn’t this method create an extra
    copy of the big text content in the
    textbox? Or is it more efficient than
    accessing the textbox control
    repeatedly?

Also if possible some ideas on keeping track of functions, brackets, braces, etc (for on-the-fly code formating) in the textbox code would be helpful.

  • 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-16T18:04:38+00:00Added an answer on May 16, 2026 at 6:04 pm

    Because you are going to have to parse the code for formatting, I would not do this from the textbox itself. I would copy the entire textbox contents into a string and read characters from the string. This is because interacting with any control adds another layer of complexity, as far as the program itself is concerned. Instead of accessing a String variable to get a character directly, you need to first access the Textbox control which then accesses it’s internal representation of your text to get the character. It’s an extra step and, for large amounts of text, it will slow your application down.

    To do the actual parsing and formatting, you can either write your own tokenizer and formatter or use one that’s already been built. I can’t offer much help on either, but unfortunately it’s not as simple as just tracking braces. Take a look at Sourceforge or similar sites; they might have formatters that you can study to help you build your own.

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

Sidebar

Related Questions

This question is about programming small microcontrollers without an OS. In particular, I'm interested
I'm learning JavaFX and this is just a small programming question. I have 3
i have made a small opengl program using the d programming language. what i
In Karl Seguin's Foundations of Programming there is a small section on using the
I am currently designing and implementing a small programming language as an extra-credit project
I'm doing some small program for a beginners programming course and in my program
I'm programming a small app with opengl for the iphone, and now I want
I am programming a small script using PHP and regular expressions The aim of
What would your own (I assume perfect) programming language look like? Give a small
I am writing a small assistant app to read (well, filter/rank) /r/programming/ for me,

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.