469,625 Members | 1,595 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

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 3835
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

20 posts views Thread by Ioannis Vranos | last post: by
5 posts views Thread by murlbrown | last post: by
1 post views Thread by Someonekicked | last post: by
1 post views Thread by Patty O'Dors | last post: by
reply views Thread by murlbrown | last post: by
12 posts views Thread by yufufi | last post: by
5 posts views Thread by michael | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.