I need to capture when the user presses CTRL-Z
(press CTRL
and Z
at the same time) in a RichTextBox control.
I've turned off the ShortCutsEnabled
property. I've tried every combination I can think of using KeyCode
and KeyData
with the KeyDown
and KeyPress
events.
I can capture EITHER a CTRL
OR a Z
, but never both together. Is RichTextBox
capturing this keystroke before I can see it, even if shortcuts are disabled?
Does anyone have a solution that works for this?
Creating a RichTextBox control at run-time is merely a work of creating an instance of RichTextBox class, setting it's properties and adding the RichTextBox object to the Form's Controls collection. The first step to create a dynamic RichTextBox is to create an instance of the RichTextBox class.
The following code snippet disables shortcuts in a RichTextBox. The simplest way of reading a RichTextBox control contents is using the Text property. Note however that the Text property has no formatting; it has only text. See the Rtf property for the text including the formatting.
RichTextBox control supports drag and drop operations that allow us to drag and drop text, picture, and other data. EnableAutoDragDrop property enables drag-and-drop operations on text, pictures, and other data. RightMargin property represents the size of a single line of text within a RichTextBox control.
The simplest way of reading a RichTextBox control contents is using the Text property. Note however that the Text property has no formatting; it has only text. See the Rtf property for the text including the formatting.
you could simply use CTRL-Z
textBox1.KeyDown += new KeyEventHandler(textBox1_KeyDown);
void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode == Keys.Z && (e.Control)) {
MessageBox.Show("Ctrl + Z Pressed!");
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With