如何DoubleBuffered
在遭受闪烁的表单上设置控件的受保护属性?
我有一个readonly数据记录窗口,我使用RichTextBox控件实现.我希望能够禁用用户单击控件时发生的自动滚动,以便用户可以选择特定日志进行复制/粘贴操作或其他任何操作.但是,只要用户点击RichTextBox,它就会自动滚动到底部,这使得这很困难.
有人知道一种方法来覆盖这种行为吗?
谢谢!
我有一个RichTextBox,一旦用户加载文件,我的程序就会继续扫描整个文件,以便更改某些单词的颜色.这是我的代码:
static Regex cKeyWords = new Regex(@"\b(?=[a-gilr-w])(?:
s(?:hort|i(?:gned|zeof)|t(?:atic|ruct)|witch) | c(?:ase|har|on(?:st|tinue)) |
e(?:lse|num|xtern) | i(?:f|nt) | f(?:loat|or) | d(?:o|efault|ouble) | un(?:ion|signed) |
re(?:gister|turn) | vo(?:id|latile) | while | break | long | typedef | auto | goto
)\b",
RegexOptions.Compiled | RegexOptions.IgnorePatternWhitespace);
...
programTextBox.Enabled = false;
int selectStart = this.programTextBox.SelectionStart;
programTextBox.SuspendLayout();
MatchCollection matches = cKeyWords.Matches(programTextBox.Text);
foreach (Match match in matches)
{
if (match.Index == 0)
programTextBox.Select(match.Index, match.Length/* - 1*/);
else
programTextBox.Select(match.Index + 1, match.Length - 1);
programTextBox.SelectionColor = Color.Blue;
}
programTextBox.Select(selectStart, 0); …
Run Code Online (Sandbox Code Playgroud)