Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving to the end of some text in a TMemo component

Status
Not open for further replies.

markmetcalfe

Programmer
Apr 2, 2005
3
GB
I am trying to write some code that will move the cursor to the end of a date in a memo edit when I click a button.

Can anyone help?
 
If possible, I would swap your TMemo for a TRichEdit because TRichEdit has a routine called FindText into which you can pass your date string.

A google search for "delphi caret TRichEdit" brought back the following sites, which will be of interest to you:

Let us know how you get on.

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Thanks for the information Stretchwikster. however, I am still unable to get the cursor to move to the end of the date.

Mark
 
Stretchwikster I have managed to sort out my problem by doing the same search you carried out.

The following code sorted out the problem.

procedure TCirculationForm.AddNotesBtnClick(Sender: TObject);
begin
NotesEdit.Lines.Add(DateToStr(Now) + ':');
RichEdit_MoveTo(notesedit,notesedit.Lines.Count -1,11);
Application.ProcessMessages;
notesedit.SetFocus;

end;

Thank you for your help

Mark
procedure TCirculationForm.RichEdit_MoveTo(RichEdit: TRichEdit; LineNumber, CharNumber: Word);
begin
notesedit.SelStart := notesedit.Perform(EM_LINEINDEX, LineNumber, 0) + CharNumber;
end;
 
do you want to move the cursor to the end of the text or the end of a date in the text.

how can you control that the date has been entered correctly so that your code knows how to find it ????

Aaron Taylor
John Mutch Electronics
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top