473,387 Members | 1,464 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.

Help with protected text in RichTextBox

I need to programmatically delete protected text in a RichTextBox. The
problem is that I can't find a way to do it without getting
undesirable results in the undo buffer.

If I unprotect the text and delete, 2 entries go into the undo buffer.
If the user performs a single undo, they get back the text unprotected.

If I copy the entire RTF text, make my changes and copy it back, the
undo buffer is initialized.

Any ideas?
Thanks!

Nov 28 '06 #1
2 4158
Do you have some code to explain what you said?

chanmm

<ML****@hotmail.comwrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...
>I need to programmatically delete protected text in a RichTextBox. The
problem is that I can't find a way to do it without getting
undesirable results in the undo buffer.

If I unprotect the text and delete, 2 entries go into the undo buffer.
If the user performs a single undo, they get back the text unprotected.

If I copy the entire RTF text, make my changes and copy it back, the
undo buffer is initialized.

Any ideas?
Thanks!
Nov 30 '06 #2
// start is the starting position of the protected text.
// end is the final position of the protected text.

// OPTION #1: Results in two "undo" entries.
MyRichTextBox.SelectionStart = start;
MyRichTextBox.SelectionLength = end - start + 1;
MyRichTextBox.SelectionProtected = false;
MyRichTextBox.SelectedRtf = "";

// OPTION #2: Results in "undo" buffer being initialized.
RichTextBox temp = new RichTextBox();
temp.Rtf = MyRichTextBox.Rtf;
temp.SelectionStart = start;
temp.SelectionLength = end - start + 1;
temp.SelectionProtected = false;
temp.SelectedRtf = "";
MyRichTextBox.Rtf = temp.Rtf;
temp.Dispose();

chanmm wrote:
Do you have some code to explain what you said?

chanmm

<ML****@hotmail.comwrote in message
news:11*********************@j72g2000cwa.googlegro ups.com...
I need to programmatically delete protected text in a RichTextBox. The
problem is that I can't find a way to do it without getting
undesirable results in the undo buffer.

If I unprotect the text and delete, 2 entries go into the undo buffer.
If the user performs a single undo, they get back the text unprotected.

If I copy the entire RTF text, make my changes and copy it back, the
undo buffer is initialized.

Any ideas?
Thanks!
Dec 1 '06 #3

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

Similar topics

2
by: PC User | last post by:
I found some VB code to printout a richtext field and I'm trying to adapt it to MS Access 2000. I think there might be some small changes to make the adaption between VB versions. Also my OS is...
3
by: kangoo | last post by:
Hi, I'm trying to remove the last charater in a richTextBox. I though richTextBox.Text.Remove(richTextBox.Text.length-1, 1); would work, but it does nothing (eg richTextBox.Text += "some new...
1
by: a_deano | last post by:
Hi, I am not totally new to programming for Windows but may have bitten off more than I can chew. My problem is, I would like to install a hook (using SetWindowsHookEx) to monitor mouse...
6
by: Martin Heuckeroth | last post by:
Hi, We are looking for a way to determine the x and y points of the cursor in a richtext box. We made an VB.NET application with a couple of listboxes and one of them is a richtextlistbox....
0
by: Srig007 via DotNetMonster.com | last post by:
I am having a hard time trying to display characters into the richtextbox everytime I drag a button into it. I successfully got the button to be dragged and dropped into the richtextbox, but I...
0
by: Claudiu | last post by:
Is posible that erase protected areas in RichTextBox and press undo the protected area to remain protected, not to be added to the richtextbox plain text
6
by: cj | last post by:
Lets just take this example I'm looking at now. I'm looking at the help screen titled .NET Framework Class Library FolderBrowserDialog Class . It gives an example at the bottom that begins with:...
8
by: Lee | last post by:
Hi all, I'm trying to programatically change the background color of lines of text and running into a few difficulties, anyone got any suggestions? my relevant code is as follows: public void...
0
by: Vimalathithan | last post by:
I just developing a editor. I have provide the options like Bold, Italic, underlin, font change, font size change. These font options are keep in with one toolstripbutton. the toolstripbar keep...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
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
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...

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.