473,411 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

problem handling backspace key

C#
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!
Nov 16 '05 #1
3 5221
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!

Nov 16 '05 #2
Dan you dont know how much i appreciate your help!
As for building the html after the user is done i could do that but the
problem is is i am allowing the user to place images into the rtb. what i
was doing was using rtbHiddent.Text += "<img src='"+dlgOpen.FileName+"'>";
to insert the image tag. If i were to place the html tags in afterwards
there isnt any filename or hints of where the image is from in rtf. i.e.-
the rtf coding for an image is something like
"{\pict{.....}02352464F20000000235234210003246023. ....}"
http://msdn.microsoft.com/library/de...ml/rtfspec.asp
has more info on the rtf syntax. So the solution would work except for the
fact that somehow i would have to track the image filenames and the position
they are to be at. Thank you so much for the help Dan!

"Dan Bass" <danielbass [at] postmaster [dot] co [dot] uk> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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!


Nov 16 '05 #3
RTF -> Html ...

I found this

http://www.codeguru.com/Cpp/controls...cle.php/c5377/
not sure if he has pictures though.

Good luck.

"NuBBeR" <be************@hotmail.com> wrote in message
news:uu**************@TK2MSFTNGP15.phx.gbl...
Dan you dont know how much i appreciate your help!
As for building the html after the user is done i could do that but the
problem is is i am allowing the user to place images into the rtb. what i
was doing was using rtbHiddent.Text += "<img src='"+dlgOpen.FileName+"'>";
to insert the image tag. If i were to place the html tags in afterwards
there isnt any filename or hints of where the image is from in rtf. i.e.-
the rtf coding for an image is something like
"{\pict{.....}02352464F20000000235234210003246023. ....}"
http://msdn.microsoft.com/library/de...ml/rtfspec.asp
has more info on the rtf syntax. So the solution would work except for the
fact that somehow i would have to track the image filenames and the
position they are to be at. Thank you so much for the help Dan!

"Dan Bass" <danielbass [at] postmaster [dot] co [dot] uk> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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!



Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dennis Craven | last post by:
Hello, Does anyone know how one could insert a backspace into a widget such as a TextView/Buffer in Pygtk? Whenever I try something like insert(iter, '\b') I get jibberish inserted into the...
1
by: haxmya | last post by:
Ok, made an explorer toolbar (band Object) with a textbox on it. Everything works great....except that the backspace button doesn't actually backspace when you're in the textbox. Shift-backspace...
6
by: Robert Nurse | last post by:
Hi, Is it at all possible to capture and suppress the backspace key when focus is not on a form edit control? Basically, while the page is loading I don't want the user pressing the backspace...
2
by: Tom Gerstner | last post by:
Dear all, I'm trying to program a IE Toolbar similar to the Google Bar in C# using Band Objects. Everything works fine but my TextBox (which I use to search the Internet) is not responding the...
12
by: Joel Byrd | last post by:
I'm having a little problem with using type-ahead functionality for an auto-suggest box. Sometimes, when I start to type something and the type-ahead shows up, the AJAX will send a request query...
2
by: key9 | last post by:
Hi all on last post I confused on how to organize file of class, ok ,the problem solved : should include class define head on cpp file. but this time ,still link error: strange is I put the...
0
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I have a scrolling RichTextBox to which I add characters one at a time using the AppendText method as they are received by my application. Some of these characters may be backspace...
1
by: Blue | last post by:
This JS limits the input characters into the form. How do I modify it so that it also allows CARRIAGE RETURN and BACKSPACE (for making text correction)? Due to the template engine I am using, I...
2
by: skanemupp | last post by:
so my little calculator works perfectly now. just having some trouble with the layout. this whole tkinter-thing seems to be more tricky than it should be. how can i make the 4 column of buttons...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.