) To make
sure a text box supports the Enter key, set AcceptsReturn to True. You can also set AcceptsTab
to allow the user to insert tabs. Otherwise, the Tab key moves to the next focusable control in
the tab sequence.
nTip The TextBox class also includes a host of methods that let you move through the text content programmatically
in small or large steps. They include LineUp(), LineDown(), PageUp(), PageDown(),
ScrollToHome(), ScrollToEnd(), and ScrollToLine().
Sometimes, you??™ll create a text box purely for the purpose of displaying text. In this case,
set the IsReadOnly property to True to prevent editing. This is preferable to disabling the text
box by setting IsEnabled to False because a disabled text box shows grayed-out text (which is
more difficult to read), does not support selection (or copying to the clipboard), and does not
support scrolling.
Text Selection
As you already know, you can select text in any text box by clicking and dragging with the
mouse or holding down Shift while you move through the text with the arrow keys. The
CHAPTER 7 n CLASSIC CONTROLS 207
TextBox class also gives you the ability to determine or change the currently selected text programmatically,
using the SelectionStart, SelectionLength, and SelectedText properties.
SelectionStart identifies the zero-based position where the selection begins.
Pages:
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403