相关疑难解决方法(0)

如何在表单上双重缓冲.NET控件?

如何DoubleBuffered在遭受闪烁的表单上设置控件的受保护属性?

c# doublebuffered flicker winforms

48
推荐指数
8
解决办法
6万
查看次数

防止在RichTextBox中自动滚动

我有一个readonly数据记录窗口,我使用RichTextBox控件实现.我希望能够禁用用户单击控件时发生的自动滚动,以便用户可以选择特定日志进行复制/粘贴操作或其他任何操作.但是,只要用户点击RichTextBox,它就会自动滚动到底部,这使得这很困难.

有人知道一种方法来覆盖这种行为吗?

谢谢!

c# richtextbox winforms

11
推荐指数
2
解决办法
1万
查看次数

语法突出显示性能问题

我有一个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)

c# regex syntax-highlighting richtextbox winforms

7
推荐指数
1
解决办法
316
查看次数