Inserting multiple lines in textbox

I have textbox with multilne parameter set to true
How do i add multiple lines of text

I guess i have to use array somehow


Answer this question

Inserting multiple lines in textbox

  • John W. Smith

    You can also use an array:



    string[] lines = new string[] { "Hello", "World" };
    textBox1.Lines = lines;

     




    List<string> lines = new List<string>();
    lines.Add("Hello");
    lines.Add("World");
    textBox1.Lines = lines.ToArray();

     




  • DaveQ2

    Perhaps you could try this, which I am currently using to show variable values in a summary box for testing reasons.

    I've got a SummaryBox (which is a "listbox")

    SummaryBox.Items.Add ("");
    SummaryBox.Items.Add ("Equipment Type: " + EquipmentType.Text);
    SummaryBox.Items.Add ("----------------------------------------");
    SummaryBox.Items.Add ("Transaction Type: " + transactiontype.Text);

    On the button click, the above code is ran and the proper display shows in the SummaryBox.

    Hope this helps!
    -Corby-


  • Toni Chaffin

    Hi,


    You can use



    Environment.NewLine;

     


    to add a new line (by code)


    HTH.

    Bye.

  • Inserting multiple lines in textbox