This depends on how much data they're entering in... If you're not expecting
them to enter all that much (less that a couple of thousand characters say),
then the solution is a little easier.
if the original text is something like:
"Hello World!"
and you then do this in your second text box
"<html>
<head><title>New Text</title></head>
<body>
<p>Hello World!</p>
</body>
</html>"
The easiest way would definately NOT be to track each key press and alter
the second text box one at a time... If I press the left cursor seven times
and then typed "Blue Skied ", you'd expect the resulting text to be "Hello
Blue Skied World!" not "Hello World!Blue Skied". I presume this is where
your problems are coming in with backspaces and delete presses...
What I would suggest is to simply generate the text in the new text box once
the user has finished typing what they need to (if this is an option) or, if
you MUST, on each key press... You could do this by doing the following:
StringBuilder sb = new StringBuilder ();
sb.Append ( "<html>\r\n" );
sb.Append ( "<head><title>New Text</title></head>\r\n" );
sb.Append ( <body>\r\n" );
sb.Append ( "<p>" );
sb.Append ( firstTextbox.Text );
sb.Append ( "</p>\r\n" );
sb.Append ( "</body>\r\n" );
sb.Append ( "</html>" );
textboxSecond.Text = sb.ToString();
Let me know if you need any more help.
Dan.
"C#" <be************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I have a richtextbox that i am copying to an invisible richtextbox .
during the keydown and keypress events i am inserting HTML tags into the
invisble richtextbox along with the origional text. The only problem i am
running into is when the user presses the backspace and delete key i have a
hard time knowing how to erase the charater(s) desired from the invisible
richtextbox because it contains additional text. Any help is GREATLY
appreciated. Thanks in advance!