Guest User

Untitled

a guest
Mar 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. private void Form1_Load(object sender, EventArgs e) {
  2.  
  3. dataGridView1_Konfiguration();
  4. //txtPerson => ID texteditor
  5. txtPerson.Focus();
  6. txtPerson.SelectionStart = txtPerson.Text.Length;
  7.  
  8. }
  9.  
  10. private void txtPerson_KeyPress(object sender, KeyPressEventArgs e){
  11.  
  12. if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar)){
  13. e.Handled = true;
  14. }
  15. }
  16.  
  17.  
  18. private void txtPerson_KeyDown(object sender, KeyEventArgs e)
  19. {
  20. if (e.KeyCode == Keys.Enter && txtPerson.Text == ""){
  21.  
  22. MessageBox.Show("Bitte geben ein gültige Personalnummer !!");
  23. }
  24. else if (e.KeyCode == Keys.Enter && txtPerson.Text != ""){
  25.  
  26. dataGridView1.Enabled = true;
  27. dataGridView1.Focus();
  28. dataGridView1.Rows[0].Cells[1].Selected = true;
  29. }
  30. }
  31.  
  32. e.SuppressKeyPress = true;
  33.  
  34. private void txtPerson_KeyDown(object sender, KeyEventArgs e)
  35. {
  36. if (e.KeyCode == Keys.Enter && txtPerson.Text == "")
  37. {
  38.  
  39. MessageBox.Show("Bitte geben ein gültige Personalnummer !!");
  40. }
  41. else if (e.KeyCode == Keys.Enter && txtPerson.Text != "")
  42. {
  43.  
  44. dataGridView1.Enabled = true;
  45. dataGridView1.Focus();
  46. dataGridView1.Rows[0].Cells[1].Selected = true;
  47. e.SuppressKeyPress = true;
  48. }
  49. }
Add Comment
Please, Sign In to add comment