It is necessary to make so that when data appears in the buffer for rollback, the cancel button is activated. When there is no more data in the buffer that can be rolled back, but there is to repeat - the repeat button is activated and the cancel button is deactivated. Accordingly, when there is data for rollback and retry, 2 buttons worked. I could not find information on a specific issue, so I did it in my own way. When I enter characters in RichtextBox - the cancel button is activated.
private void RichTextBox_KeyUp(object sender, KeyEventArgs e) { if (Clipboard.ContainsText() == true) { cancel.Enabled = true; } } When I press the cancel button, a repeat is activated.
private void cancel_Click(object sender, EventArgs e) //отмена последнего события { RichTextBox.Undo(); if (Clipboard.ContainsText() == true) { repeat.Enabled = true; } else { repeat.Enabled = false; } } private void repeat_Click(object sender, EventArgs e) //повтор последнего события { RichTextBox.Redo(); if (Clipboard.ContainsText() == false) { cancel.Enabled = false; } } Despite the incorrect approach, everything works, but at those moments when there is nothing more to roll back - the buttons remain active. What advise?