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

Going to the bottom of EditBox

Status
Not open for further replies.

Goofus828

Programmer
Nov 9, 2005
127
US
Hi all, I've read [blue] thread1254-1352455 [/blue] and I have a similar situation. I post progress messages to the editbox and as the message grows, I want go to the bottom of the message. I've tried what was suggested in the prior thread but to no success. This is my code.

cString is my message

Code:
frmmain.edtMessage.VALUE = frmmain.edtMessage.VALUE + cString
frmmain.edtMessage.SETFOCUS
frmmain.edtMessage.REFRESH
frmmain.edtMessage.SELSTART = 0
frmmain.edtMessage.SELLENGTH = LEN(frmmain.edtMessage.VALUE )
KEYBOARD "{Ctrl+end}"

All this does is highlight the text from the top to the bottom but never does it move the cursor to the bottom of the edit box.


Any help is appreciated.
Thanks.
 
Basically, you've got too much code. This is all you need:

Code:
frmmain.edtMessage.VALUE = frmmain.edtMessage.VALUE + cString
frmmain.edtMessage.SETFOCUS
frmmain.edtMessage.SELLENGTH = LEN(frmmain.edtMessage.VALUE )

If that doesn't work, try switching round the last two lines.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Where did you place the code, What Method?


David W. Grewe Dave
 
Set SelStart to len(value), that moves the scrollbar to the bottom. SelLen does not matter, unless you want everything to appear selected/inverted.

Bye, Olaf.
 
Like Olaf suggested:

****Editbox INIT() or gotfocus() if not the first control

***Cursor is after the last character in edit box
thisform.edit1.SelStart = LEN(thisform.edit1.VALUE)+1

**Cursor in New line,
thisform.edit1.SelStart = LEN(thisform.edit1.VALUE)+1
KEYBOARD '{ENTER}'

If setting focus from another control:
add the following to the above
thisform.edit1.SETFOCUS()
 
I post progress messages to the editbox and as the message grows, I want go to the bottom of the message.

Code:
KEYBOARD "{Ctrl+end}"

In the edit box's GotFocus() should do it for you.

However, an alternative approach might be to use a listbox instead. Code like this to display progress:

Code:
WITH Thisform.lstProgress
  .AddItem( 'This is a progress message...' )
  .ListIndex = .NewIndex
ENDWITH

Marcia G. Akins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top