Only the Rich-
TextBox has the ability to store more sophisticated content: a FlowDocument that can contain
a complex combination of elements.
In the following sections, you??™ll consider the core features of the TextBox. You??™ll end by
taking a quick look at the security features of the PasswordBox.
nNote The RichTextBox is an advanced control design for displaying FlowDocument objects. You??™ll learn
how to use it when you tackle documents in Chapter 19.
Multiple Lines of Text
Ordinarily, the TextBox control stores a single line of text. (You can limit the allowed number of
characters by setting the MaxLength property.) However, there are many cases when you??™ll
want to create a multiline text box for dealing with large amounts of content. In this case, set
CHAPTER 7 n CLASSIC CONTROLS 206
the TextWrapping property to Wrap or WrapWithOverflow. Wrap always breaks at the edge of
the control, even if it means severing an extremely long word in two. WrapWithOverflow
allows some lines to stretch beyond the right edge if the line-break algorithm can??™t find a suitable
place (such as a space or a hyphen) to break the line.
To actually see multiple lines in a text box, it needs to be sized large enough. Rather than
setting a hard-coded height (which won??™t adapt to different font sizes and may cause layout
problems), you can use the handy MinLines and MaxLines properties.
Pages:
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401