Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Calling <code>text1.Text.ToLower()</code> will not make the text in your rich text box to be in lower case, because it just returning value.</p> <p>You can keep it in a string:</p> <p><code>string text = text1.Text.ToLower();</code></p> <p>Then using the string text to process the searching.</p> <p>Moreover, I don't quite sure about the <code>Find</code> method, but it should has a ignore case option. If not, make sure to convert the compared text to lowercase too.</p> <p>EDIT:</p> <p>I may be mistaken about which one is the richTextBox, <code>text1</code> or <code>Basic_Word_Processor.Instance.richTextBoxPrintCtrl1</code></p> <p>If the case is the one in Basic_Word_processor, then in the MSDN link you give in the comment:</p> <pre><code> string temp = Basic_Word_Processor.Instance.richTextBoxPrintCtrl1.Text.ToLower(); Basic_Word_Processor.Instance.richTextBoxPrintCtrl1.Text = ""; Basic_Word_Processor.Instance.richTextBoxPrintCtrl1.Text = temp; </code></pre> <p>It basically said: </p> <ul> <li>Convert the text in the RichTextBox to lowercase. Keep it in temp</li> <li>Set the RichTextBox text ot empty</li> <li>Replace the RichTextBox text with the temp</li> </ul> <p>Of course it makes your RichTextBox lowercase.</p> <p>EDIT2:</p> <p>Ok seems like the user want to highlight all the found text by given keyword and it is not working. I'll try to answer it.</p> <p>First, Rather than using the Find() method in the rich text box, use the <code>SelectionStart</code> and <code>SelectionLength</code> instead. I don't see the Find() method to give case insensitive comparison. </p> <p>Example:</p> <pre><code>string richText = Basic_Word_Processor.Instance.richTextBoxPrintCtrl1.Text.ToLower(); string keyText = textBox1.Text.ToLower(); </code></pre> <p>In the while syntax, use the overload string LastIndexOf to compare non-case sensitive. This may not be a matter now as the rich is already in lower state.</p> <pre><code>while (index &lt; richText.LastIndexOf(textBox1.Text, StringComparison.InvariantCultureIgnoreCase)) </code></pre> <p>Then to find the text, use the following:</p> <pre><code>index = richText.IndexOf(keyText, index); </code></pre> <p>Then set the color like this:</p> <pre><code>Basic_Word_Processor.Instance.richTextBoxPrintCtrl1.SelectionStart = index; Basic_Word_Processor.Instance.richTextBoxPrintCtrl1.SelectionLength = keyText.Length; Basic_Word_Processor.Instance.richTextBoxPrintCtrl1.SelectionBackColor = Color.Yellow; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload