简体   繁体   中英

System.Windows.Forms.RichTextBox's implementation of TextBoxBase.ClearUndo()

According to MSDN , the description of the method ClearUndo is:

"Clears information about the most recent operation from the undo buffer of the text box."

Now, contrary to what the documentation says, the override of this method in System.Windows.Forms.RichTextBox appears to be clearing the entire undo buffer, instead of just the most recent operation. Is this discrepancy between the documentation and the implementation a known issue, or should I suspect that something else it amiss? I have been unable to find any official information on this which is why I am now asking the question here. I have tested it with .NET Framework 4.0 .

You are correct. ILSpy shows this in TextBoxBase (the RichTextBox doesn't override it):

public void ClearUndo()
{
    if (base.IsHandleCreated)
    {
        base.SendMessage(205, 0, 0);
    }
}

The message 205 is EM_EMPTYUNDOBUFFER :

// Header file
#define EM_EMPTYUNDOBUFFER 0x00CD // 0x00CD = 205

// C#
EM_EMPTYUNDOBUFFER = 205

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM