Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language

Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C# Programming

Moving the caret in a multiline RichTextBox


I'm trying to implement a backspace on the "bottom" line of a multiline text
box.  I want it to be ignored if it's already at the beginning of that line.  
I think I've got the part about removing each character from the string that
represents that line, but how do I back up the caret?  I understand .NET 3.0
has implemented a method for doing backspaces, but I'd like to know how to do
it manually since not many people around here have installed 3.0.


Ray - Try using the Select method of the textbox with the new starting
position and a length of 0.  That should do the trick.

Gregg Walker


Sorry I left this out.  Additionally you will probably want to call
ScrollToCaret after calling Select.  This will bring the caret into view if
your scroll bars are in use.


int newPos;

... backspace logic

newPos = p;

text1.Select(p, 0);

Hope that helps.

Gregg Walker

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc