public partial class Form1 : Form { public Form1() { InitializeComponent(); foreach (Control item in this.Controls ) { item.MouseClick += Item_MouseClick; } } private void Item_MouseClick(object sender, MouseEventArgs e) { if (keypressed) { if (textBox1.Text.Contains("W")) { MessageBox.Show("why you wrote Well, quickly wiped!"); } else { MessageBox.Show("Here! and another thing!"); keypressed = false; } } } bool keypressed = false; private void textBox1_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == 'W') { keypressed = true; } } }
Find more questions by tags C#Windows Forms
:) - helene35 commented on July 9th 19 at 13:42