LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Text Box - Auto Scroll ?

Hi

 

How would i move the Texbox Vertical Scrollbar to the newest inserted line ?

 

Thanks in advance .

Help share your knowlegde
0 Kudos
Message 1 of 9
(6,605 Views)

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);



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 9
(6,600 Views)
You can use SetCtrlVal. When you call SetCtrlVal on a text box, SetCtrlVal appends the string to the contents of the text box and scrolls the text box to display the string.
Message 3 of 9
(6,580 Views)

I have tried all of the  suggested solution and none of them scrolls the textbox.

Is there any other way to do so ?

Help share your knowlegde
0 Kudos
Message 4 of 9
(6,549 Views)

Please forgive the question, but are you talking about a text box, or a list box?

 

--Ian

Message Edited by Ian W on 12-15-2009 09:44 AM
0 Kudos
Message 5 of 9
(6,538 Views)

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.

Help share your knowlegde
0 Kudos
Message 6 of 9
(6,531 Views)

As jared suggested, I always add lines to the end of a Text Box with SetCtrlVal(). Works for me.

 

JR

0 Kudos
Message 7 of 9
(6,521 Views)

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.

 

Message 8 of 9
(5,453 Views)

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;
}

 

Message 9 of 9
(5,432 Views)