First encountered the disobedience of the program on Winforms:
btn.Enabled = true; // было false, отрабатывает корректно - стало true btn.Visible = true; // было false, отрабатывает неправильно - остается false Exceptions do not crash. I tried to call
System.Windows.Forms.Application.DoEvents(); before, in the middle and after the 1st block of code. Does not help.
What's wrong with the program?
Here is a more complete version of the code:
foreach (Button btn in buttonsList) { btn.Visible = false; btn.Enabled = false; btn.ForeColor = Color.Black; btn.BackgroundImage = null; btn.FlatStyle = FlatStyle.Standard; btn.Margin = new Padding(0, 5, 0, 5); } foreach (string num in _list) { foreach (Button btn in buttonsList) { if(btn.Text == num) { // Вот на этом моменте уже не работает btn.Enabled = true; btn.Visible = true; } } }