Let's say I've got a control and I want to prevent it from being edited.
Setting the Enabled property of the control to False will work but the control appearance will change accordingly, usually to a difficult to read black over gray font. When readability is still important, this is a real problem.
For a TextBox, there are a few obvious fixes :
Textbox1.BackColor = Color.White;
or
Textbox1.ReadOnly= true; // instead of setting Enabled to false
but unfortunately this won't work for every controls (eg radio buttons)
Another solution is to let the Enabled property untouched, and to subscribe to the focus event like this (but this isn't a really 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 of dealing with this problem? (and I mean real world solutions ; of course you can capture a screenshot of the control and display the copy over the control...:p)