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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:22:24+00:00 2026-05-27T14:22:24+00:00

How can i add a line of text to a multi-line TextBox ? e.g.

  • 0

How can i add a line of text to a multi-line TextBox?

e.g. pseudocode;

textBox1.Clear();
textBox1.Lines.Add("1000+");
textBox1.Lines.Add("750-999");
textBox1.Lines.Add("400-749");
...snip...
textBox1.Lines.Add("40-59");

or

textBox1.Lines.Append("brown");
textBox1.Lines.Append("brwn");
textBox1.Lines.Append("brn");
textBox1.Lines.Append("brow");
textBox1.Lines.Append("br");
textBox1.Lines.Append("brw");
textBox1.Lines.Append("brwm");
textBox1.Lines.Append("bron");
textBox1.Lines.Append("bwn");
textBox1.Lines.Append("brnw");
textBox1.Lines.Append("bren");
textBox1.Lines.Append("broe");
textBox1.Lines.Append("bewn");

The only methods that TextBox.Lines implements (that i can see) are:

  • Clone
  • CopyTo
  • Equals
  • GetType
  • GetHashCode
  • GetEnumerator
  • Initialize
  • GetLowerBound
  • GetUpperBound
  • GetLength
  • GetLongLength
  • GetValue
  • SetValue
  • ToString

enter image description here

  • 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-27T14:22:25+00:00Added an answer on May 27, 2026 at 2:22 pm

    @Casperah pointed out that i’m thinking about it wrong:

    • A TextBox doesn’t have lines
    • it has text
    • that text can be split on the CRLF into lines, if requested
    • but there is no notion of lines

    The question then is how to accomplish what i want, rather than what WinForms lets me.

    There are subtle bugs in the other given variants:

    • textBox1.AppendText("Hello" + Environment.NewLine);
    • textBox1.AppendText("Hello" + "\r\n");
    • textBox1.Text += "Hello\r\n"
    • textbox1.Text += System.Environment.NewLine + "brown";

    They either append or prepend a newline when one (might) not be required.

    So, extension helper:

    public static class WinFormsExtensions
    {
       public static void AppendLine(this TextBox source, string value)
       {
          if (source.Text.Length==0)
             source.Text = value;
          else
             source.AppendText("\r\n"+value);
       }
    }
    

    So now:

    textBox1.Clear();
    textBox1.AppendLine("red");
    textBox1.AppendLine("green");
    textBox1.AppendLine("blue");
    

    and

    textBox1.AppendLine(String.Format("Processing file {0}", filename));
    

    Note: Any code is released into the public domain. No attribution required.

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

Sidebar

Related Questions

How can i add a line break to the text area in a html
How can I add a line break to text when it is being set
In wiki you can add horizontal line just by adding ---- in the text
I am trying to add a multi-line text field to a document within Sharepoint
How can I add line breaks in my language file for use in MFMailComposeViewController
I can add and remove the last line in my dynamic form and calculate
How can I add a second line (smaller font) below the navigationBar title as
How can we add a striped line to an Excel chart using C#? I
I have line: imagejpeg($this->image, $file, $quality); How can add on this image watermark.png?
How can I add a start up item via command line on a mac?

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.