Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public partial class Form1 : Form
- {
- private Boolean _didLostFocusLogic;
- public Form1()
- {
- InitializeComponent();
- }
- private void textBox1_Leave(object sender, EventArgs e)
- {
- LostFocusLogic();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- ButtonClickLogic();
- }
- private void LostFocusLogic()
- {
- /* Do stuff */
- _didLostFocusLogic = true;
- }
- private void ButtonClickLogic()
- {
- if (!_didLostFocusLogic)
- LostFocusLogic();
- _didLostFocusLogic = false; // Reset for next time.
- /* Do stuff */
- }
- }
- Button b = (Button) sender;
- b.Focus();
Add Comment
Please, Sign In to add comment