【问题标题】:How to highlight specific text shown in a multiline textbox?如何突出显示多行文本框中的特定文本?
【发布时间】:2014-08-15 16:49:05
【问题描述】:

在我的应用程序中,我必须突出显示 API 返回的一些文本(不正确的单词)以显示在多行文本框中。 如何突出显示 API 返回的字符串中的特定单词。 我的代码是

 ServiceReference1.GetTextSoapClient c = new GetTextSoapClient();
 string text = c.GetTextFromImage(@"D:\Files\OCR\" + FileUpload1.FileName);
 txtContent.Text = text;
 List<string> list_Words = GetWords(text);

如何突出显示文本中的特定单词。

【问题讨论】:

    标签: c# javascript jquery asp.net highlighting


    【解决方案1】:

    如果您只想在多行文本框中选择一个单词,您必须先找到该单词:

    int start_index = textBox1.Text.IndexOf("word");
    

    然后突出显示它:

    textBox1.Focus();
    textBox1.Select(start_index, word lenght);
    

    但是如果你想选择多个单词并改变颜色、高亮背景等等......你必须使用富文本框

    【讨论】:

      猜你喜欢
      • 2013-01-23
      • 1970-01-01
      • 2018-02-16
      • 1970-01-01
      • 2015-07-19
      • 1970-01-01
      • 1970-01-01
      • 2012-06-26
      • 2020-04-17
      相关资源
      最近更新 更多