HighlightText

HighlightText(string, Color)

Highlights all matches of the sample text with the specified color.

public void HighlightText(string text, Color highlightColor)
ParameterTypeDescription
textStringThe text to highlight.
highlightColorColorThe color to highlight the text.

See Also


HighlightText(string, Color, ITextSearchOptions, IFindResultCallback)

Highlights all matches of the sample text with the specified color.

public void HighlightText(string text, Color highlightColor, ITextSearchOptions options, 
    IFindResultCallback callback)
ParameterTypeDescription
textStringThe text to highlight.
highlightColorColorThe color to highlight the text.
optionsITextSearchOptionsText search options ITextSearchOptions.
callbackIFindResultCallbackThe callback object for receiving search results IFindResultCallback.

Examples

The following code sample shows how to highlight text in a TextFrame.

[C#]
using (Presentation presentation = new Presentation("SomePresentation.pptx"))
{
	// highlighting all words 'important'
	((AutoShape)presentation.Slides[0].Shapes[0]).TextFrame.HighlightText("important", Color.LightBlue);
	// highlighting all separate 'the' occurrences
	((AutoShape)presentation.Slides[0].Shapes[0]).TextFrame.HighlightText("the", Color.Violet, new TextSearchOptions()
	{ WholeWordsOnly = true }, null);
	presentation.Save("SomePresentation-out2.pptx", SaveFormat.Pptx);
}

See Also