Board index » delphi » Set cursor/caret at end of text?

Set cursor/caret at end of text?

Hi

I read/write RichEdit formatted texts that are stored in an array of
TMemoryStream.
When I select one (any) of them the caret is set to the beginning of the
text instead the end of it?
I use SetFocus, is there an easy/other way to set the Cursor/caret at the
end of my text?

I think my problem could be that my RichEdit component  are alone on top of
a TPanel, this results in that it is the only object in taborder.
I've noticed that if RichE. is placed among other components (more can
focus) it put it's cursor/caret at the end of the text. (works as expected)

                                Thanks
                                       Nils

 

Re:Set cursor/caret at end of text?


Nil:

 richedit.selstart := Length(richedit.text);
 richedit.perform(EM_SCROLLCARET, 0, 0);

--
Regards
Ralph (TeamB)
(No private e-mail replies, please, unless explicitly requested).
--

Quote
TTS wrote in message <76se9l$a...@forums.borland.com>...

|Hi
|
|I read/write RichEdit formatted texts that are stored in an array of
|TMemoryStream.
|When I select one (any) of them the caret is set to the beginning of the
|text instead the end of it?
|I use SetFocus, is there an easy/other way to set the Cursor/caret at the
|end of my text?
|
|I think my problem could be that my RichEdit component  are alone on top of
|a TPanel, this results in that it is the only object in taborder.
|I've noticed that if RichE. is placed among other components (more can
|focus) it put it's cursor/caret at the end of the text. (works as expected)
|
|                                Thanks
|                                       Nils
|
|

Re:Set cursor/caret at end of text?


Quote
> I read/write RichEdit formatted texts that are stored in an array of
> TMemoryStream.
> When I select one (any) of them the caret is set to the beginning of the
> text instead the end of it?

 with richedit do begin
   selstart := gettextlen;
   perfrom( em_scrollcaret, 0, 0 );
 end;

The caret will only be visible if the control has the focus, of course.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitely requested!

Other Threads