A document consists of different text parts: The main text, headers, footers and text frames. The TextPartCollection is a meta collection that allows the iteration of document elements in all document parts. The IFormattedText interface provides properties and methods common to all text parts in a TX Text Control document.

Additionally, an object of type IFormattedText has a separate Find method. In order to find and highlight a specific string in all text parts, the following easy code snippet can be used:

public void HighlightAll(string Text)
{
        foreach (TXTextControl.IFormattedText obj in textControl1.TextParts)
        {
                int index = -1;

                do
                {
                        index = obj.Find(Text, index + 1,
                                TXTextControl.FindOptions.NoMessageBox);
                        
                        obj.Selection.TextBackColor = Color.Red;
                } while (index != -1);
        }
}

As a result, all instances of a specific string ("TEST") are highlighted in red:

Find and highlight strings in all text parts