Chapter 19. Programming Windows Forms Applications

When .NET first came to life, there were two ways to create applications: ASP.NET for web applications, and Windows Forms for Windows applications. Although WPF offers many advantages over Windows Forms, Microsoft realizes that there are a great many Windows Forms applications already up, tested, and working, and that many companies will choose to maintain and extend them.

Our interest in this book is how we can use C# to interact with Windows Forms, and in this chapter we'll look at building a nontrivial application using this technology. Figure 19-1 shows the application we're going to build. It is a Windows application for copying files from one or more directories to a target directory, written in Windows Forms and designed to be run on a Windows computer (this application has been tested on Windows XP, 2000, and Vista).

The File Copier application

Figure 19-1. The File Copier application

Once again, because this is a C# book and not a Windows programming book, we're going to make fast work of the UI and focus on the code-behind file and the event handlers—that is, on the C#. Unlike with WPF, however, there is no declarative aspect to Windows Forms; you create the UI by dragging objects onto a form, and then interacting with those objects by clicking on them and setting their properties, either in the Properties window at design time, or programmatically ...

Get Programming C# 3.0, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.