See: How to change the font color of a disabled TextBox?
[Edit - code example added]
richTextBox.TabStop = false;
richTextBox.ReadOnly = true;
richTextBox.BackColor = Color.DimGray;
richTextBox.Cursor = Cursors.Arrow;
richTextBox.Enter += richTextBox_Enter;
private void richTextBox_Enter(object sender, EventArgs e)
{
// you need to set the focus somewhere else. Eg a label.
SomeOtherControl.Focus();
}
or as en extension method (I realized you don't have to put it in readonly since the Enter event catches any input):
public static class MyExtensions
{
public static void Disable( this Control control, Control focusTarget )
{
control.TabStop = false;
control.BackColor = Color.DimGray;
control.Cursor = Cursors.Arrow;
control.Enter += delegate { focusTarget.Focus(); };
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…