txt1.Enabled = cb1.Checked;
lst1.Enabled = !cb1.Checked;
This works fine. However, we repeat the reference to the check box state twice.
There is a way to write the above statements on the same line:
lst1.Enabled = !(txt1.Enabled = cb1.Checked);
Looks simple when you get it right. But it took me a few minutes to figure it out.
No comments:
Post a Comment