Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Inserting text into TEdit and TMultiLineEdit
Thu, Oct 11 2018 10:14 PMPermanent Link

Paul Coshott

Avatar

Hi All,

I have a TEdit (for email subject) and a TMultiLineEdit for email message. The user is able to use variables in both of these, by entering things like %STAFF_NAME%.

I would like to allow the user to click on a Label and then insert the variable text into the TEdit or TMultiLineEdit at the current cursor position. Can anyone tell me how to do this?

Thanks heaps,
Paul
Sat, Oct 13 2018 7:08 AMPermanent Link

Uli Becker

Paul,
 
> I would like to allow the user to click on a Label and then insert the variable text into the TEdit or TMultiLineEdit at the current cursor position. Can anyone tell me how to do this?

For a TMultiLineEdit you can use the SelectionStart property, e.g.:

procedure TForm1.Button1Click(Sender: TObject);
var
   p: Integer;
begin
   p := MultiLineEdit1.SelectionStart;
   MultiLineEdit1.Lines.Text := Copy(MultiLineEdit1.Lines.Text, 1, p) + ' %STAFF_NAME% ' + Copy(MultiLineEdit1.Lines.Text, MultiLineEdit1.SelectionStart+1, Length(MultiLineEdit1.Lines.Text));
end;

With a TEdit component it won't work though.

Uli
Tue, Oct 16 2018 6:09 AMPermanent Link

Paul Coshott

Avatar

Hey Uli,

>>    MultiLineEdit1.Lines.Text := Copy(MultiLineEdit1.Lines.Text, 1, p) + ' %STAFF_NAME% ' +
>> Copy(MultiLineEdit1.Lines.Text, MultiLineEdit1.SelectionStart+1, Length(MultiLineEdit1.Lines.Text));
>> end;

Thanks heaps mate. Appreciate it.

Cheers,
Paul
Image