Highlight selected word in cell

I'm using AdvStringGrid to build a list of lines from a RichEdit control where a selected word is found. Is it possible to selected the same selected word in each cell and make it bold so that the results stand out?

You'd need to set the text background & text color to selected colors for the text you want to highlight in RTF. Just the attribute 'selected' for a part of the text is not propagated to RTF rendering in a grid cell.

Changing the color is fine. How do I select the word to change the text color. In a RichEdit I use SelStart and SelLength to select the word which can then have the text color changed, but I can't seem to do this in a cell.

This code snippet demonstrates this:


begin
  AdvStringGrid1.Cells[1,1] := 'Hello world';
  AdvStringGrid1.CellToRich(1,1, AdvStringGrid1.RichEdit);

  AdvStringGrid1.RichEdit.SelStart := 6;
  AdvStringGrid1.RichEdit.SelLength := 5;
  AdvStringGrid1.RichEdit.SelAttributes.Color := clRed;

  AdvStringGrid1.RichToCell(1,1, AdvStringGrid1.RichEdit);
end;

Thanks Bruno, that has solved the highlighting problem I had.

However it has introduced another problem. I was using AutoSizeRows to set each cell to the height of the text which can be a couple of words or up to 40 to 50 words. This no longer works once the lines are set to RicheEdit.

I sit possible to have variable sized rows to accommodate various lengths of Riche Edit text?