Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
59
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 button1_MouseDown(object sender, MouseEventArgs e)
  2. {
  3. foreach (Control t in this.Controls)
  4. {
  5. if (t is TextBox)
  6. {
  7. if (t.Focused)
  8. {
  9. MessageBox.Show(t.Name);
  10. }
  11. }
  12. }
  13. }
  14.  
  15. private Control _focusedControl;
  16.  
  17. private void TextBox_GotFocus(object sender, EventArgs e)
  18. {
  19. _focusedControl = (Control)sender;
  20. }
  21.  
  22. private void button1_Click(object sender, EventArgs e)
  23. {
  24. if (_focusedControl != null)
  25. {
  26. //Change the color of the previously-focused textbox
  27. _focusedControl.BackColor = Color.Red;
  28. }
  29. }
  30.  
  31. private void BtnKeyboard_Click(object sender, EventArgs e)
  32. {
  33. if (MasterKeyboard.Visible)
  34. {
  35. btnKeyboard.ButtonImage = Properties.Resources._001_22;
  36. MasterKeyboard.Visible = false;
  37. _lastFocusedControl.Focus();
  38. }
  39. else
  40. {
  41. btnKeyboard.ButtonImage = Properties.Resources._001_24;
  42. MasterKeyboard.Visible = true;
  43. MasterKeyboard.BringToFront();
  44. _lastFocusedControl.Focus();
  45. }
  46. }
  47.  
  48. private Control _lastFocusedControl;
  49. private void BtnKeyboard_MouseHover(object sender, EventArgs e)
  50. {
  51. if (ActiveControl!=btnKeyboard)
  52. _lastFocusedControl = ActiveControl;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement