Say I have a control and I want it to not be edited.
Setting the Enabled property of the control to False will work, but the appearance of the control will change accordingly, as a rule, to hard to read black over gray font. When readability is still important, this is a real problem.
There are several obvious fixes for TextBox:
Textbox1.BackColor = Color.White;
or
Textbox1.ReadOnly= true; // instead of setting Enabled to false
but unfortunately this will not work for each control (e.g. radio buttons)
Another solution is to enable the Enabled property and subscribe to this focus event (but this is not a very elegant solution)
this.Textbox1.Enter += new System.EventHandler(this.Textbox1_Enter); private void Textbox1_Enter(object sender, EventArgs e) { Textbox1.FindForm().ActiveControl = null; }
Have you seen other ways to solve this problem? (and I mean real solutions, of course, you can capture a screenshot and display a copy above the control ...: p)
Brann
source share