6.6. The List Box for Unformatted Output

Up to this point we have been directing our text to a console window. A somewhat more visually appealing alternative is to direct our output to the list box of a Windows Forms window. For example, Figure 6.12 displays the content of a text file directed into a simple form containing only a list box. As configured, the vertical and horizontal scrolling is added as needed. The program is virtually unchanged, although factored out into an independent function:

Figure 6.12. The Windows Forms List Box Window

 private void process_file( string file_name ) { StreamReader ifile = File.OpenText( file_name ); string ...

Get C# Primer: A Practical Approach now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.