【问题标题】:Highlighting whole lines in RichTextBox突出显示 RichTextBox 中的整行
【发布时间】:2016-02-11 11:51:32
【问题描述】:

我试图突出显示 RichTextBox 中的整行。现在我有这个方法

if (Current != null)
{
    selectStart = this.textBox.Text.Length;
    foreach (string s in Current.Details)
    {
        this.textBox.AppendText(s + Environment.NewLine);
    }
    selectEnd = this.textBox.Text.Length;
    this.textBox.Select(selectStart, selectEnd - selectStart);
    this.textBox.SelectionBackColor = Color.FromArgb(51, 255, 51);
}

但这只会突出显示文本,如下所示:

我希望代码突出显示整个行长。有没有办法做到这一点?

【问题讨论】:

  • 也许您可以使用列表框并覆盖绘制事件?
  • 并非如此。我需要它是一个 RichTextBox。

标签: c# winforms


【解决方案1】:

我认为你不能做你想做的事,因为 RichTextBox 不支持盒子模型(就像浏览器会使用 <div> 块一样)。它只会装饰文本本身。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-07-23
    • 1970-01-01
    • 2015-05-05
    • 2011-08-06
    • 2015-05-10
    • 2015-12-12
    • 1970-01-01
    相关资源
    最近更新 更多