472,368 Members | 2,422 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,368 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 3922
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.