12-14-2009 02:34 AM
Hi
How would i move the Texbox Vertical Scrollbar to the newest inserted line ?
Thanks in advance .
12-14-2009 04:30 AM
When using a textbox there are two aspects to consider: the position of the caret (i.e. where the new text will be instered) and the actual line shown on the visible part of the control.
To move the caret to the end of the text in the textbox you can use the selection attributes of the control:
SetCtrlAttribute (panelHandle, PANEL_TEXTBOX, ATTR_TEXT_SELECTION_START, strlen (text));
I am supposing here that 'text' is the variable loaded in the textbox.
On the other hand, to actually show the last position of the textbox on screen afterpositioning the caret to the end of the text you can fake pressing the arrow key, this way:
SetActiveCtrl (panelHandle, PANEL_TEXTBOX);
FakeKeystroke (VAL_RIGHT_ARROW_VKEY);
12-14-2009 11:09 AM
12-15-2009 06:19 AM
I have tried all of the suggested solution and none of them scrolls the textbox.
Is there any other way to do so ?
12-15-2009 08:39 AM - edited 12-15-2009 08:44 AM
Please forgive the question, but are you talking about a text box, or a list box?
--Ian
12-15-2009 08:49 AM
Im talking about a TextBox.
I have changed the app to use ListBoxes just to make it easier.
But i would still like to know how to do it with a TextBox.
12-15-2009 09:08 AM
As jared suggested, I always add lines to the end of a Text Box with SetCtrlVal(). Works for me.
JR
08-17-2012 01:44 PM
I noted if you add multiple lines with a single SetCtrlVal() call it will position at the first line. You need to add each line individually.
08-22-2012 08:02 AM
I think call with empty string could work: SetCtrlVal(panel,control,"");
however i use somethink different (mostly in combination with SetCtrlAttribute(panel,control,ATTR_CTRL_VAL, ) )
void SetAtEndOfTextBox(int panel,int control) {int lines; int FirstLine; int VisibleLines; GetCtrlAttribute(panel,control,ATTR_VISIBLE_LINES,&VisibleLines); GetNumTextBoxLines(panel,control,&lines); FirstLine=0; if (lines>VisibleLines) { FirstLine=lines-VisibleLines; } SetCtrlAttribute (panel,control, ATTR_FIRST_VISIBLE_LINE, FirstLine); return; }