delphi-2009synedit

How to replace a selected text in synedit?


I'm doing a custom text editor in Delphi with SynEdit and i'm at a loss with a simple need:

I want to have a popup button that, when clicked, replace the selected text with an uppercase version of that text. I think i have to use SelStart y SelEnd, but i'm not sure how can i do it.

I went into google and find mentions of a "La biblia de SynEdit" but the links were dead, so i ended here, hoping for a helpful soul who can answer my questions or has a copy of that bible.


Solution

  • Set SelStart to the beginning of the text, and SelLength to the length of that text (or, alternatatively, set SelEnd to the end of the text), and then assign your new text using SelText. This is the same way it works in the VCL.TRichEdit component.

    SynEdit1.SelStart := 1;
    SynEdit1.SelLength := Length(NewText);
    SynEdit1.SelText := NewText;