Главная страница | назад





Article #17777: Positioning the caret in an edit control.

 Question and Answer Database
FAQ2777D.txt Positioning the caret in an edit control.
Category :VCL
Platform :All
Product :All 32 bit
Question:
How do I position the cursor (caret) in an edit or similar type
control?
Answer:
You can use the Delphi SelStart() and SelectLength() methods.
Example:
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.SetFocus;
{Move the caret to the second character}
Edit1.SelStart := 2;
{Do not select any text}
Edit1.SelLength := 0;
end;
7/16/98 4:31:28 PM

Last Modified: 01-SEP-99