473,671 Members | 2,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5242
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>Ne w 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>N ew Text</title></head>\r\n" );
sb.Append ( <body>\r\n" );
sb.Append ( "<p>" );
sb.Append ( firstTextbox.Te xt );
sb.Append ( "</p>\r\n" );
sb.Append ( "</body>\r\n" );
sb.Append ( "</html>" );
textboxSecond.T ext = sb.ToString();

Let me know if you need any more help.

Dan.


"C#" <be************ @hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.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{.....}0 2352464F2000000 023523421000324 6023.....}"
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******** ********@TK2MSF TNGP11.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>Ne w 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>N ew Text</title></head>\r\n" );
sb.Append ( <body>\r\n" );
sb.Append ( "<p>" );
sb.Append ( firstTextbox.Te xt );
sb.Append ( "</p>\r\n" );
sb.Append ( "</body>\r\n" );
sb.Append ( "</html>" );
textboxSecond.T ext = sb.ToString();

Let me know if you need any more help.

Dan.


"C#" <be************ @hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.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******** ******@TK2MSFTN GP15.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{.....}0 2352464F2000000 023523421000324 6023.....}"
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******** ********@TK2MSF TNGP11.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>Ne w 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>N ew Text</title></head>\r\n" );
sb.Append ( <body>\r\n" );
sb.Append ( "<p>" );
sb.Append ( firstTextbox.Te xt );
sb.Append ( "</p>\r\n" );
sb.Append ( "</body>\r\n" );
sb.Append ( "</html>" );
textboxSecond.T ext = sb.ToString();

Let me know if you need any more help.

Dan.


"C#" <be************ @hotmail.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.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
2329
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 buffer. Thanks, ~djc
1
1732
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 works but regular backspace doesn't. Does anyone have any ideas? Posted Via Usenet.com Premium Usenet Newsgroup Services ----------------------------------------------------------
6
15597
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 key which IE interprets as a desire to return to the previous page. Thanks
2
3475
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 accelerated keys like "backspace". I do not even get the KeyDown/KeyPress event for this keys for the textbox :-( (I assume my IE (parent window?) catches these events before). How can I solve this?
12
5125
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 using the value that *includes* the type-ahead value. In other words, say that I type in "ja" and the first listing that comes up is "jack@test.com". The AJAX part is supposed to send "ja" as one of the query string variables when calling the...
2
1871
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 implement to .h file directly like this: *******head file***** class LinuxTestTerminal : public Terminal{ public:
0
1544
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 characters, which I need to somehow use to erase the most recent character displayed in the last line displayed in the text box. Of course, the backspace must only apply to the last line and must not back up into the previous line once all characters...
1
6260
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 cannot use IF/ELSE statement. ============================== <form> <textarea name="event_description" ONKEYPRESS="if (document.layers)
2
3520
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 have the same distance and size between them as the other 3 columns? and how can i make the top entry end where the 2nd row entry ends(meaning the top entry will be longer)? why are the 4th row split from the others? hard to fix the problems...
0
8393
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8914
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8598
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7433
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6223
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4224
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2810
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2051
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.