Get the format of a char in a CRichEditCtrl (or RichTextBox) without selecting it

262 Views Asked by At

Either C++ or C# solutions are welcome.

I have the index of a character in a text displayed in a RichEditCtrl. I need to know its format (is it bold, red, etc) without selecting it.

Thank you all.

1

There are 1 best solutions below

1
Joseph Willcoxson On

Using the base CRichEditCtrl, there is no way to get the format of a char without selecting it. If you don't want to change the selection, then save the start/end position of the current selection, select the character you want the format of, call CRichEditCtrl::GetSelectionCharFormat(), and then restore the original selection of the rich edit control.