Results 1 to 6 of 6

Thread: *SOLVED* Adding text to a textbox programmatically

  1. #1

    Thread Starter
    Addicted Member DJ_Catboy's Avatar
    Join Date
    Jan 2003
    Location
    Suffolk, UK
    Posts
    159

    *SOLVED* Adding text to a textbox programmatically

    Hi,

    Really stupid easy stupid question probably...

    I want to add some data to a text box but using code. So I am doing...

    Code:
    textBox1.AppendText("AddressLine\n\r");
    I have added this code to a button, repeated presses make the textbox's contents as follows:

    AddressLineAddressLineAddressLine

    And then when I count the number of lines it is showing as 3 - however the carriage returns are not working correctly!

    Please can somebody help me!

    Thanks,
    DJ
    Last edited by DJ_Catboy; Jan 19th, 2004 at 03:56 AM.

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    is the textboxes multiline property set to true?
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3
    Hyperactive Member Sgt-Peppa's Avatar
    Join Date
    Mar 2003
    Location
    Munich - Germany
    Posts
    476
    Make sure you added System.Text.RegularExpressions;,
    set your textbox to multiline = true (like Memnoch1207 said) and change the order of the Expression. Do \r\n instead of \n\r.

    HTH,

    Stephan
    Keep Smiling - even if its hard
    Frankie Says Relax, wossname Says Yeah!
    wossname:--Currently I'm wearing a gimp suit and a parachute.
    C# - Base64 Blog

  4. #4
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    you can do it this way
    VB Code:
    1. textBox1.Text = textCheck1.Text + "Check" + System.Environment.NewLine;
    Or
    VB Code:
    1. textBox1.AppendText("Check\r\n");
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  5. #5
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    textBox1.Text += "Check" + System.Environment.NewLine;

  6. #6

    Thread Starter
    Addicted Member DJ_Catboy's Avatar
    Join Date
    Jan 2003
    Location
    Suffolk, UK
    Posts
    159
    Thank you all for your help!

    DJ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width