locking textbox scrolling

  • Thread starter Thread starter simonc
  • Start date Start date
S

simonc

Is there a way of locking the display of two text boxes,
so that as you scroll down in one text box the display is
automatically scrolled in the other?

The issue is to display line numbers for a file beside the
file, but in a separate text box, so that I don't confuse
the text from the file with the line numbering text. I can
also then show the line numbers in a different colour
which helps distinguish them.
 
simonc said:
Is there a way of locking the display of two text boxes,
so that as you scroll down in one text box the display is
automatically scrolled in the other?

The issue is to display line numbers for a file beside the
file, but in a separate text box, so that I don't confuse
the text from the file with the line numbering text. I can
also then show the line numbers in a different colour
which helps distinguish them.

Is the textbox readonly? If it is, you could split the content at CRLF and
add the line number to each item in the string array. Afterwards, join the
single lines and put it in the textbox. You can also use a RichTextbox to be
able to use different colours.
 
* "Armin Zingler said:
Is the textbox readonly? If it is, you could split the content at CRLF and
add the line number to each item in the string array. Afterwards, join the
single lines and put it in the textbox. You can also use a RichTextbox to be
able to use different colours.

This will include the line number when selecting the text and copying it
to the clipboard.

;-)
 
Herfried K. Wagner said:
This will include the line number when selecting the text and copying
it to the clipboard.

;-)

Right, but I don't know whether it is desired or not. If it's not, it was
worth an attempt. :-)
 
* "Armin Zingler said:
Right, but I don't know whether it is desired or not. If it's not, it was
worth an attempt. :-)

ACK, I didn't want to critisize your approach.

;-)
 
Thanks to Armin and Herfried for your responses. I will
try adding the line numbers to the text string.

The ideal appearance I was aiming at was something like
you get with MS Excel when opening a text file. In the
Text Import Wizard Step 1 of 3 it displays a preview of
the file, with line numbers at the left side which remain
visible even when you scroll the file to the right (if it
is more than 65 characters wide). If you scroll down the
file the line numbers also remain in step with the text
file lines. I am curious as to how that is achieved.

When you look at text in a text box and use the scroll
bars to look at a piece of the file which is not visible
how is the text box implementing the action of the scroll
bar? Is there a property of the text box which sets the
limits of the displayed text both horizontally and
vertically? If so you could control that for two text
boxes simultaneously using a scroll bar control added to
the form.

Simon C
 
simonc said:
Thanks to Armin and Herfried for your responses. I will
try adding the line numbers to the text string.

The ideal appearance I was aiming at was something like
you get with MS Excel when opening a text file. In the
Text Import Wizard Step 1 of 3 it displays a preview of
the file, with line numbers at the left side which remain
visible even when you scroll the file to the right (if it
is more than 65 characters wide). If you scroll down the
file the line numbers also remain in step with the text
file lines. I am curious as to how that is achieved.

When you look at text in a text box and use the scroll
bars to look at a piece of the file which is not visible
how is the text box implementing the action of the scroll
bar? Is there a property of the text box which sets the
limits of the displayed text both horizontally and
vertically? If so you could control that for two text
boxes simultaneously using a scroll bar control added to
the form.

Hi Simon,

now I see what you mean. Well, I'd probably use a ListView to imitate this
behavior. Maybe using a DataGrid is an alternative, or, if you don't find a
control that fits your needs, you could also try to write your own control.
I think the latter is not too complicated, but I also think using a
readonly Textbox or a ListView is the fastest solution.
 
Back
Top