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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Position cursor at specific position in a memo field

Status
Not open for further replies.

wtotten

IS-IT--Management
Apr 10, 2002
181
US
I have a memo field that already contains data. I have a simple form that has a editbox controlsourced to a memo field. I want to add a line at the beginning to the existing data in the memo field and have the cursor (in the editbox) positioned at the end of that new line I added to the beginning of the existing memo. The line I add to the beginning at the memo is something that looks like this:
05-01-2018 Bill Totten:

I want the cursor to be at the end of line next to the ":".

I can add the new line to the existing memo data and put the cursor at the end of the line I added. The problem is when I want to add the new line to the beginning of the existing memo data.

Bill
 
Morning, you seem to be looking to pop a new text line on a memo (in an edit box?) and position the cursor at the end of that line?
People quite often do things like this on ERM systems - using a button on a form to add a comment with a time, date and user name to a memo

The key is the selstart and sellength properties of the editbox.

If you were using a button to do this, the Click event code might look like:

Code:
local lcNewLine
lcNewLine = DTOC(Date())+" "+time()+" "+gcCurrentUser+": "
thisform.CommentsBox.Value = lcNewLine+chr(13)+chr(10)+thisform.CommentsBox.Value
thisform.CommentsBox.SelStart = Len(lcNewLine)
thisform.CommentsBox.SelLength = 0
thisform.CommentsBox.Setfocus()

If your data is bound to the edit box, the underling memo should be updated, otherwise, you could pop the update into the controls 'lostfocus' event.




Regards

Griff
Keep [Smile]ing

There are 10 kinds of people in the world, those who understand binary and those who don't.

I'm trying to cut down on the use of shrieks (exclamation marks), I'm told they are !good for you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top