• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 477
  • Last Modified:

Car Return in Text Box

Hi, my name is Alex.

Using C#:

I have a text box in my program and every 30 characters I want to add a car return character.

//Example:

if (this.txtRemarks .Text .Length == 30)
                  {
this.txtRemarks .Text += “\n”;
                  }


When I this is executed the cursor returns to the beginning of the line but does not go to the next line.

I tried to enter (char)13 but is doing the same.

I was using a regular text box from tools and I changed it for Rich text box; It still doing the same.

Can any one help me please;
0
cyborgcom
Asked:
cyborgcom
1 Solution
 
StillUnAwareCommented:
You must set an option of text box to be multiline
0
 
cyborgcomAuthor Commented:
Multiline is true

I am able to enter text and car returns my self but when that condition is true only retuen the car to the beginning and does not create a new line
0
 
cyborgcomAuthor Commented:
is there other oprion to insert a car return?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Jaime OlivaresSoftware ArchitectCommented:
try with:
this.txtRemarks .Text += “\r\n”;
0
 
StillUnAwareCommented:
You can try adding the windows native new line characters:

13 followed by 10
0
 
cyborgcomAuthor Commented:
You mean :

this.txtRemarks .Text += (char)13 + (char)10      ?
0
 
cyborgcomAuthor Commented:
this.txtRemarks .Text += “\r\n”;

Still not working
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
How about...

        private void txtRemarks_TextChanged(object sender, EventArgs e)
        {
            if (txtRemarks.TextLength % 30 == 0)
            {
                txtRemarks.AppendText(Environment.NewLine);
            }
        }
0
 
cyborgcomAuthor Commented:
Idle_Mind

I am trying to do the same but in a FormField TextBox in Office Word 2003
Can you help me with the Macro?
0
 
cyborgcomAuthor Commented:
I have a Text Box and I want to break this string just like the c# example you showed me
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now