I have a C# WinForms sample application, demonstrating interesting key handling issue.
That's very simple: there is just a Form
and TextBox
on it. I set TextBox
ReadOnly
property to true
.
I have the next code in my Form
:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyData.HasFlag(Keys.R))
{
MessageBox.Show("There is 'R' key in KeyDown event");
}
}
}
When I press Ctrl-R keys, the MessageBox
doesn't show up. But if I set ReadOnly
property of TextBox
to true
, the MessageBox
appears. The same thing happens, when I press Shift-R or Alt-R on ReadOnly
TextBox
.
Any ideas, what is special with ReadOnly
TextBox
and Ctrl-R combination?