G
Guest
In my WinForms app I wanted to implement a Read-Only textbox. I didn't like
the appearance a textbox takes on when the ReadOnly property is set true so
instead I trapped the KeyPress event with a generic event handler:
private void textBoxMakeReadOnly(object sender, KeyPressEventArgs e)
{
e.Handled = true;
}
I *thought* this was working perfectly until I selected some characters and
pressed 'Delete'. It didn't trap the Delete key! I even tried monitoring
the KeyDown event but no luck there either.
So how does one trap the pressing of the Delete key?
the appearance a textbox takes on when the ReadOnly property is set true so
instead I trapped the KeyPress event with a generic event handler:
private void textBoxMakeReadOnly(object sender, KeyPressEventArgs e)
{
e.Handled = true;
}
I *thought* this was working perfectly until I selected some characters and
pressed 'Delete'. It didn't trap the Delete key! I even tried monitoring
the KeyDown event but no luck there either.
So how does one trap the pressing of the Delete key?