473,387 Members | 1,844 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,387 software developers and data experts.

Programmatic Delete of last char in a Richedit

The title says it all. Since a Richedit control doesn't understand a
backspace character ('\b', or 0x08) when I receive one I need to
programmatically delete the last character from the Richedit control.
This is a WinForms application, not a webform.

I have tried...
re.SelectionLength = 1;
re.SelectionStart = re.Textlength-1;
re.SelectionText = ""; // empty string

but that doesn't seem to delete the last character. It stays there.

Any advice from anyone?

Oz
Nov 15 '05 #1
3 3985
ozbear,

This might be overkill, but you could always set the text like this:

re.Text = re.Text.Substring(0, re.Text.Length - 1);

If you have a lot of text though, I can see how that would be very
inefficient.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"ozbear" <oz****@no.bigpond.spam.com> wrote in message
news:3f9e20d0.186390765@news-server...
The title says it all. Since a Richedit control doesn't understand a
backspace character ('\b', or 0x08) when I receive one I need to
programmatically delete the last character from the Richedit control.
This is a WinForms application, not a webform.

I have tried...
re.SelectionLength = 1;
re.SelectionStart = re.Textlength-1;
re.SelectionText = ""; // empty string

but that doesn't seem to delete the last character. It stays there.

Any advice from anyone?

Oz

Nov 15 '05 #2
It isn't the amount of text, so much as the amount of screen
disruption that occurs. When one sets the Text like you suggest,
what effectively happens is a Clear followed by an AppendText
of the string whch puts you pack up at the top of the text and
you have to go thru scrolling up to the end of the text, restoring the
caret to the end and so forth.

There must be an easier way.

By the way...is the way I originally posted *supposed* to work?

Regards, Oz

On Tue, 28 Oct 2003 09:04:10 -0500, "Nicholas Paldino [.NET/C# MVP]"
<mv*@spam.guard.caspershouse.com> wrote:
ozbear,

This might be overkill, but you could always set the text like this:

re.Text = re.Text.Substring(0, re.Text.Length - 1);

If you have a lot of text though, I can see how that would be very
inefficient.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"ozbear" <oz****@no.bigpond.spam.com> wrote in message
news:3f9e20d0.186390765@news-server...
The title says it all. Since a Richedit control doesn't understand a
backspace character ('\b', or 0x08) when I receive one I need to
programmatically delete the last character from the Richedit control.
This is a WinForms application, not a webform.

I have tried...
re.SelectionLength = 1;
re.SelectionStart = re.Textlength-1;
re.SelectionText = ""; // empty string

but that doesn't seem to delete the last character. It stays there.

Any advice from anyone?

Oz



Nov 15 '05 #3
<snip>
Breakthrough...

My problem was (alas!) that I had the ReadOnly property for my
RichEdit set to true.

Note to the Universe...set Readonly to false if you are going to
try and delete text, programmatically or otherwise.

Oz
Nov 15 '05 #4

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

Similar topics

20
by: Ioannis Vranos | last post by:
When we use the standard placement new operator provided in <new>, and not a definition of owr own, isn't a call to placement delete enough? Consider the code: #include <new>
5
by: murlbrown | last post by:
I am using a class library built by michael kennedy that creates a system wide hook on the WH_KEYBOARD_LL, but I wanted to changed it to become a hook for a RichEdit box in another application. ...
1
by: Someonekicked | last post by:
I have a binary file, and I need to delete a specific number of characters in it. The file contains records, each record has a specific length. So the way I wanna handle deleting is that I will...
1
by: Patty O'Dors | last post by:
Hi I'm trying to create an application with a RichEdit control, I found that CreateWindow always returns a null hWnd unless I call LoadLibrary("riched20.dll") first (the error code from...
0
by: murlbrown | last post by:
I am using a class library built by michael kennedy that creates a system wide hook on the WH_KEYBOARD_LL, but I wanted to changed it to become a hook for a RichEdit box in another application. ...
12
by: yufufi | last post by:
Hello, How does delete know how much memory to deallocate from the given pointer? AFAIK this informations is put there by new. new puts the size of the allocated memory before the just before...
5
by: michael | last post by:
Hi All, I have the following: const int LENGTH = 5; void limitNameLength(string inText, char *&outText, int outLength){ if(static_cast<int>(inText.length()) outLength){ inText =...
23
by: Martin T. | last post by:
Hi all! char* p = new char; // POD! .... delete p; // std compliant delete p; // will work on VC8 free(p); // will also work on VC8 I am interested on which platforms/compilers the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.