Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stopping newline in richtextbox control

Status
Not open for further replies.

DrGryphon

MIS
Feb 18, 2003
56
AU
Hi, I have an application that uses the richtextbox control in vb.net as the main input/output mechanism.

To add text into the control I am using the .AppendText method which not only adds the text, but places the cursor on a newline. I don't want this. I want to append the text into the control and have the caret sit right at the end of the appended text waiting for user input (kind of like a command prompt).

I can of course resize the array that stores the text for the control (to get rid of the last newline), and then reposition the cursor but this introduces its own problems whereby the last line is removed before .AppendText has finished adding text to the control. The result makes me unhappy :)

Does anyone know hoe to stop AppendText from doing this, or, (less desirably) how I can be sure that AppendText has finished before the next part of my code executes and removes the last line ?

Any other suggestions will be gratefully accepted !


-Paul.
 
Are you sure the string that you're passing to [tt]AppendText[/tt] doesn't have a newline at the end? If it doesn't, [tt]AppendText[/tt] shouldn't be adding it.
 
Thanks rosenk, you indirectly lead me to the answer...

Once I realised it wasn't meant to do that by design I checked my code a little closer. I was actually executing the .AppendText in a KeyDown event (where the keydown was Enter).

The solution was as simple as handling the 'enter' manually by specifying e.Handled=true.

I think I wasted about 3 hours barking up the wrong tree.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top