This project has moved and is read-only. For the latest updates, please go here.

Select and format some text, how?

Nov 7, 2015 at 1:42 AM
I'm opening a document and I'd like to find any specific word (or string) and I'd like to bold that selection then save the file.

For example, I'd like to bold the word "programmer" in the following document:

"Do not bother the programmer while he/she is working."

Which would result in:

"Do not bother the programmer while he/she is working."

How would I code this? I can find the index using FindAll or the string FindUniqueByPattern, and I see the function ReplaceText, but how to I format the text that I've found to be bold?
Nov 7, 2015 at 4:56 PM
Edited Nov 7, 2015 at 6:34 PM
No one ever answers my questions...

I'm feeling lonely here. :(
Nov 20, 2015 at 1:25 PM
Nov 21, 2015 at 7:27 PM
That is not at all what I want to do.

I don't want to build a paragraph and add the formatting while I build it. I want to open an existing document, find some specific text (like a list of keywords) and apply formatting to those words.

It does not appear that I can use the ReplaceText function to apply formatting to the text that I'm replacing with.
Nov 21, 2015 at 7:35 PM
You should take a look at sources. It really gives you a lot of ways to discover things:
In container.cs there's a method 
public virtual void ReplaceText(string oldValue, string newValue, bool trackChanges = false, RegexOptions options = RegexOptions.None, Formatting newFormatting = null, Formatting matchFormatting = null, MatchFormattingOptions fo = MatchFormattingOptions.SubsetMatch)
Which basically means your ReplaceText does have the option to apply new formatting to the text on replace. If it doesn't work, or it doesn't give you what you need it should be possible to change it to your needs.
Marked as answer by BoltBait on 11/21/2015 at 11:59 AM
Nov 21, 2015 at 7:42 PM
Edited Nov 22, 2015 at 2:01 AM
Works like a charm. Thanks!