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

How to automatically scroll text in edit box

Status
Not open for further replies.

mkrausnick

Programmer
Apr 2, 2002
766
US
I have an edit box used for displaying the contents of an execution log. I update the editbox contents with something like "editbox.value = editbox.value + "New Status Message".

As EDITBOX.VALUE grows, I would like to always have the last portion of value displayed, with the text scrolling up as new status lines are added.

The edit box is not bound to any table field.

How do I do this?

Thanks,

Mike Krausnick
Dublin, California
 
Try something like:

STORE 'something new' TO cNewText
MyForm.edit1.SETFOCUS
MyForm.edit1.VALUE = MyForm.edit1.VALUE + cNewText
STORE LEN(cNewText) TO nSelLen
STORE LEN(MyForm.edit1.VALUE ) TO nTtlLen

MyForm.edit1.SELSTART = nTtlLen - nSelLen
MyForm.edit1.SELLENGTH= nSelLen

-or-

I prefer to use a ListBox control:

THISFORM.listReceiveText.ADDLISTITEM('New Stuff.')
THISFORM.listReceiveText.SELECTEDID(THISFORM.listReceiveText.LISTCOUNT) = .T.


-Dave S.-
[cheers]
Even more Fox stuff at:
 
mkrausnick,

Similar to Dave's proposed solution... this solution will scroll the editbox to the very bottom regardless of the length of the text added to the editbox. Cut-n-paste the code below into a prg file and run it from within VFP.

Code:
PUBLIC oForm
oForm = CREATEOBJECT("clseditboxscroll")
oForm.show()

DEFINE CLASS clseditboxscroll AS form


	Top = 0
	Left = 0
	Height = 264
	Width = 375
	DoCreate = .T.
	Caption = "Form"
	Name = "clseditboxscroll"


	ADD OBJECT edit1 AS editbox WITH ;
		Height = 144, ;
		Left = 24, ;
		Top = 36, ;
		Width = 324, ;
		Name = "Edit1"


	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 204, ;
		Left = 240, ;
		Height = 27, ;
		Width = 108, ;
		Caption = "Add More Text", ;
		Name = "Command1"


	PROCEDURE command1.Click
		thisform.edit1.VALUE = thisform.edit1.VALUE + "asgjkhdsjgkhdlkjghdsljghdsjhgldskghdksjhgd" ;
								+ "asgjkhdsjgkhdlkjghdsljghdsjhgldskghdksjhgd" ;
								+ "asgjkhdsjgkhdlkjghdsljghdsjhgldskghdksjhgd" ;
								+ "asgjkhdsjgkhdlkjghdsljghdsjhgldskghdksjhgd" ;
								+ "asgjkhdsjgkhdlkjghdsljghdsjhgldskghdksjhgd" ;
								+ "asgjkhdsjgkhdlkjghdsljghdsjhgldskghdksjhgd" ;
								+ "asgjkhdsjgkhdlkjghdsljghdsjhgldskghdksjhgd" ;
								+ "asgjkhdsjgkhdlkjghdsljghdsjhgldskghdksjhgd" ;
								+ "asgjkhdsjgkhdlkjghdsljghdsjhgldskghdksjhgd" ;
								+ "asgjkhdsjgkhdlkjghdsljghdsjhgldskghdksjhgd" ;
								+ "asgjkhdsjgkhdlkjghdsljghdsjhgldskghdksjhgd" ;
								+ "asgjkhdsjgkhdlkjghdsljghdsjhgldskghdksjhgd"
		thisform.edit1.SELSTART = LEN(thisform.edit1.VALUE)
		thisform.edit1.sellength = 0
	ENDPROC


ENDDEFINE

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
thisform.edit1.SELSTART = LEN(thisform.edit1.VALUE)
thisform.edit1.sellength = 0


Worked like a champ. Thanks!


Mike Krausnick
Dublin, California
 
mkrausnick,

Glad to hear it.

Slighthaze = NULL

[ul][li]FAQ184-2483
An excellent guide to getting a fast and accurate response to your questions in this forum.[/li][/ul]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top