解决方法
见:
How to change the font color of a disabled TextBox?
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(); }
或者作为扩展方法(我意识到你不必将它放在readonly中,因为Enter事件捕获任何输入):
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(); }; } }