How to Select the Last Word in TRichEditor

Hi Bruno,

Trying to select the last word in a TRichEditor so I can HyperLink it. How do I select a given word ?

Memo1.AddText('SampleText', clBlue);
Memo1.SelStart := Memo1.GetTextLen -1 ;
Memo1.SelectWordAtCaret; // Does not select text
Memo1.SetSelectionHyperlink('SampleText');

Regards,

John

The answer was to use Memo1.SelLength:

Memo1.SelStart := Length(Memo1.Text);
Memo1.AddText(HyperlinkText, clBlue);
Memo1.SelLength := Length(HyperlinkText);
Memo1.SetSelectionHyperlink(Hyperlinkext);

1 Like