Friends, such a task. There is a form on which there are two textBox elements and 1 button element. Initially, the button element is not active. It should become active only when at least 1 character appears in the textBox elements. I did it this way, using two checkboxes.

 public partial class Form1 : Form { bool tb1 = false; bool tb2 = false; public Form1() { InitializeComponent(); } private void textBox1_TextChanged(object sender, EventArgs e) { tb1 = true; if ((tb1 == true) && tb2 == true) button1.Enabled = true; } private void textBox2_TextChanged(object sender, EventArgs e) { tb2 = true; if ((tb1 == true) && tb2 == true) button1.Enabled = true; } } 

But I am sure that with the help of delegates and events this task can be solved much more beautifully, but I did not understand how. I would be grateful if someone tells you.

  • Your event is entering a character in any of the fields. You put a check on the number of characters in each of them. As soon as it has become more than zero in each of them, call what you need. IMHO so. Maybe wrong. - justyx
  • and what you do not like the current? everything is quite logical, except that you can shorten a bit by replacing (tb1 == true) && tb2 == true by tb1 && tb2 , the logical variables themselves can be used in conditions. - rdorn

0