473,406 Members | 2,371 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,406 software developers and data experts.

RichTextBox.CanUndo()

I noticed what I thought was peculiar behavior when I used the RichTextBox.
If you get the RTF string from a RichTextBox using the RichTextBox.Rtf
property, the RichTextBox treats this as an action that cannot be undone.
So if you would run the following code as the TextChanged event handler of a
RichTextBox called "rtbox" ....

private void rtbox_TextChanged(object sender, System.EventArgs e) {
Console.WriteLine("CanUndo 1 = " + rtbox.CanUndo);
Console.WriteLine("Rtf = " + rtbox.Rtf);
Console.WriteLine("CanUndo 2 = " + rtbox.CanUndo);
}

..... the following is always the result ....

CanUndo 1 = True
Rtf = [whatever Rtf]
CanUndo 2 = False

This makes no sense to me, and since the Text and TextLength properties of a
RichTextBox also include calls to the Rtf property, obtaining these
properties have the same effect. Initially I thought it was because a call
to the private method StreamOut(int32) is made, which might be considered as
writing to a stream and that might not be undoable. However, the same
method is also called in the SelectedText and SelectedRtf [GET] properties,
but the behavior does not repeat when these properties are used. Can anyone
explain why this happens?

TIA,
kruk

------------------
We've learnt that war is not the answer ... except to all of America's
problems.

Bart Simpson

Nov 13 '05 #1
0 1921

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

Similar topics

0
by: nouno | last post by:
I am trying to spell check a richtextbox. Through code (shown below) I save the contents of the richtextbox to a rtf file, open the rtf file in Word, spell check it, save it, and then load the ftf...
11
by: Mad Joe | last post by:
I'm using a richTextBox for editing a source code (with Syntax Highlighting) of my own programming language... How come that myRichTextBox doesn't respond to Undo/Redo functions by using default...
2
by: Alan | last post by:
Hi all, I want to hilight some syntax keywords. While parsing text, I used these properties such as SelectionStart,SelectionLength and SelectionColor of RichTextBox. Although the syntaxhilghting...
0
by: Mathieu Girard | last post by:
Hi, I'm using VS 2005 Express C# (beta) and I'm trying to use the undo/redo feature of a RichTextBox and I just can't get it to work. myRichTextBox.Canundo is always false. I did some...
0
by: Al Bahr | last post by:
Hi, Does anyone knows why using GetCharFromPosition(aPoint) on RichTextBox will clear the CanUndo flag? More importantly, How to use GetCharFromPosition and still be able to do Undo? Thanks Al...
2
by: JonnyT | last post by:
I searched high and low for an answer on how to auto scroll a richtextbox and now I finally have it. Since it took me a while to get a good efficient way of doing it that didn't require focus to...
0
by: Vincent | last post by:
Dear all, I have implemented a class to export the content of RichTextBox to image in WYSISYG mode so that line breaks on the screen are the same as exported. C# Code: public struct...
9
by: James Wong | last post by:
Hi, I use the RichTextBox in my program. It will use different language in this RichTextBox (chinese and english characters), and it set the "DualFont" and use different fonts. By the way, how...
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: 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
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...

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.