Guest User

Untitled

a guest
Nov 22nd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. TextBox tb = new TextBox();
  2. this.Controls.Add(tb);
  3.  
  4. private void tb_KeyPress(object sender, KeyPressEventArgs e)
  5. {
  6. if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) )
  7. {
  8. e.Handled = true;
  9. }
  10. }
  11.  
  12. tb.KeyPress += tb_KeyPress;
  13.  
  14. TextBox tb = new TextBox();
  15. tb.KeyPress += tb_KeyPress; //add this
  16. this.Controls.Add(tb);
  17.  
  18. private void tb_KeyPress(object sender, KeyPressEventArgs e)
  19. {
  20. if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) )
  21. {
  22. e.Handled = true;
  23. }
  24. }
Add Comment
Please, Sign In to add comment