Link to home
Create AccountLog in
Avatar of pr2501
pr2501

asked on

move cursor to beginning of next line

procedure TForm2.RichEdit1Enter(Sender: TObject);
begin
 RichEdit1.Text:=datetostr(date);
end;



When I enter in TRichEdit1 and put date into, need to move cursor to beginning of next line.
How to do that?
(now cursor is located into date line (on attached picture)).
cursor.bmp
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I guess also if he inserted the date with a line feed character at the end this would work also
richedit.lines.add( datetostr(date) + #10#13)
Avatar of pr2501
pr2501

ASKER


With my code when i click in TRichedit date(day,year,...) appears
but cursor is located in on day character:
Where in my code to add yours lines to move cursor to next line?
maybe this way

procedure TForm1.RichEdit1Click(Sender: TObject);
begin
  richedit1.Text := datetostr(now);
  richedit1.Lines.add('');
  richedit1.SelStart := length(richedit1.Text);
end;

btw. whats the sense for doing so?

meikl ;-)
Avatar of pr2501

ASKER

  I'm writing text into richedit  and then transfering it into  text file.

 For no vriting date by typing and the procede by text
i use code in first q.

But with yours code i get next: attache picture
cursor.bmp
hmm, my code works fine for me

could you post, how you do your task?
The problem is that your SelStart is reset on the MouseUp.
Try this:
procedure TForm1.RichEdit1Enter(Sender: TObject);
begin
     RichEdit1.Lines.Add(DateToStr(Now));
end;
 
procedure TForm1.RichEdit1MouseUp(Sender: TObject; Button: TMouseButton;  Shift: TShiftState; X, Y: Integer);
begin
     RichEdit1.SelStart := Length(RichEdit1.Text);
     RichEdit1.OnMouseUp := NIL;
end;

Open in new window

SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
due the expensive license issues i use the free turbo explorer edition (equals delphi 2006).

there is an onClick-event on the TRichedit

meikl ;-)
??? even if i use only the mouseUp-event like

procedure TForm1.RichEdit1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  richedit1.text := datetostr(now);
  richedit1.lines.Add('');
  richedit1.selstart := length(richedit1.Text);
end;

i cannot not reproduce the showed behaviour (by clicking/doubleclicking rondomly).
-> the cursor blinks on the second line

meikl ;-)
Avatar of pr2501

ASKER


Thank you
With next way it works.



  // ading Date(day,year,...)
procedure TForm2.Memo2Click(Sender: TObject);
begin
   Memo2.Lines.Add(DateToStr(Date));
   Memo2.SelStart := Length(Memo2.Text);
end;
 

Open in new window