Mmm ...
It will be a shot, but you said that you have KeyUp, KeyDown, and KeyPress event handlers? Have you set the e.Handled flag to true in event handlers, look here:
private void textBox1_KeyDown (object sender, KeyEventArgs e)
{
e.Handled = true;
}
private void textBox1_KeyUp (object sender, KeyEventArgs e)
{
e.Handled = true;
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
e.Handled = true;
}
, MSDN . ( MSDN 2008 SP 1 , ms-help://MS.MSDNQTR.v90.en/fxref_system.windows.forms/html/dfc80b44-1d79-6315-cbea-1388a048c018.htm)
:
Handled is implemented differently by different controls within Windows Forms.
For controls like TextBox which subclass native Win32 controls, it is
interpreted to mean that the key message should not be passed to the underlying
native control.
If you set Handled to true on a TextBox, that control will not pass the key
press events to the underlying Win32 text box control, but it will still
display the characters that the user typed.
, i.e. e.Handled = false;, TextChanged?
?
: dreadprivateryan, (- ), , e.Handled , Enter false , , , .
- Enter? , KeyUp, KeyDown ...
- ...
- , , , KeyDown, KeyUp Event Handler, , , , , , , , . . , SO.
keyUp . KeyPress 0-9, . - backspace .
private void textBox1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter) SendKeys.Send("{TAB}");
}
private const string VALID_KEYS = "0123456789";
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (VALID_KEYS.IndexOf(char.ToUpper(e.KeyChar)) != -1 || e.KeyChar == (char)8)
e.Handled = false;
else
e.Handled = true;
}
, ,
,
.