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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:44:50+00:00 2026-05-29T23:44:50+00:00

I am trying to have a multi line textbox that when you type in

  • 0

I am trying to have a multi line textbox that when you type in it streams it to the label, BUT the label has to have a max length of 15 so like once it reaches 15 characters in the textbox it should start overwriting the label since it reached it’s max length

thanks to anyone who can help

  • 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-29T23:44:52+00:00Added an answer on May 29, 2026 at 11:44 pm

    I’m not sure what kind of overwriting You want to achieve.

    There are at least three methods you can use:

    • displaying always the last 15 characters from the textbox, as described in the Olivier’s answer

    • clearing the label’s text each 15 characters inserted and start filling in the label over again, you can use this code to achieve this:

      private void textBox1_TextChanged(object sender, EventArgs e)
      {
          String text = textBox1.Text.Replace("\r\n", "|");
      
          int startIndex = ((text.Length - 1) / 15) * 15;
      
          label1.Text = text.Substring(Math.Max(0, startIndex));
      }
      
    • you can also overwrite char by char when text length is over 15 characters, however, I suppose it’s not what you would like to achieve, because it would cause a mess in the textbox ;), however, it can be used as a kind of visual effect :). If you want code snippet for this, let me know :).
      Update
      Here’s the code for the third overwriting method:

      String lastText = "";
      private void textBox1_TextChanged(object sender, EventArgs e)
      {
          String textBoxText = textBox1.Text.Replace("\r\n", "|");
      
          if (textBoxText.Length > lastText.Length)
          {
              int charIndex = (textBoxText.Length - 1) % 15;
      
              if (charIndex >= 0)
              {
                  label1.Text = label1.Text.Insert(charIndex, textBoxText.Substring(textBoxText.Length - 1));
                  if (charIndex < textBoxText.Length - 1)
                  {
                      label1.Text = label1.Text.Remove(charIndex + 1, 1);
                  }
              }
          }
          else
          {
              int charIndex = textBoxText.Length % 15;
      
              if (textBoxText.Length >= 15)
              {
                  label1.Text = label1.Text.Insert(charIndex, textBoxText[textBoxText.Length - 15].ToString());
                  if (charIndex < textBoxText.Length - 1)
                  {
                      label1.Text = label1.Text.Remove(charIndex + 1, 1);
                  }
              }
              else
              {
                  label1.Text = label1.Text.Remove(label1.Text.Length - 1, 1);
              }
          }
      
          lastText = textBoxText;
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string that looks like this. It's obviously a multi-line string and
I am trying to create a multi line string in Groovy. I have a
I'm trying to perform a search-replace in several JCLs but I need multi-line capabilities,
I have log file of multi threaded application. Each line has a well know
I am trying to make a horizontal nav that can contain multi-line content in
I'm trying to prepend a string a read-only, multi-line TextBox using the following code:
I have been trying to learn multi-threaded programming in C# and I am confused
I have a textbox, and I'm trying to print to it with the following
I have an input <input> When someone pastes multi-line text into the input, I
I have a problem with my XML that I am trying to display on

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.