Summary

  • C# and Visual Studio are designed to create Windows applications with visual design tools that enable you to drag-and-drop controls onto a form.

  • The application window itself is called a form, and the items that you drag onto the form are known as controls.

  • Windows applications use an event-driven design, meaning that the application responds to events raised by the user or the system, and most of your code will reside in event handlers.

  • Windows automatically provides the code to initialize the form and the controls; you don’t need to write any of it.

  • The Properties window allows you to change the properties of a control without having to edit the code by hand.

  • The Events window (available from a button in the Properties window) helps you to create event handlers for all the possible events for your control. Simply double-click the event, and Visual Studio will create a skeleton event handler and then take you to the appropriate point in the code, so you can enter your logic.

  • You can double-click a control itself to have Visual Studio create the default event handler for that control.

  • Visual Studio divides the Design view of the form from the code page, where the code for the event handlers is kept.

  • The partial keyword in the class definition indicates that Visual Studio is hiding the initialization code for the form and the controls. The partial class file is where you keep your event handler code.

  • Windows has a number of built-in classes and methods that you can use to control aspects of the form, including the Application class and the Form class.

  • Factoring is a technique where you place common code, used by several different methods or handlers, in a single dedicated method for easier access.

Now you’ve taken C# beyond the console window and into the realm of creating Windows applications. As you’ve seen, it’s not that hard, and Visual Studio takes care of a lot of the Windows fundamentals for you, leaving you free to concentrate on your code. There’s a lot more to learn about Windows programming than we can cover in this chapter, and we hope that if you’re interested, you’ll seek out other sources to learn more, and of course, experiment on your own.

The Windows Forms system has been around for a while, though. The newest version of the Windows programming framework is the Windows Presentation Foundation (WPF), which ships with Windows Vista and is also available for Windows XP SP2 and Windows Server 2003. Although you can be sure that Windows Forms will be available for a long while yet, the next chapter will bring you up-to-date with the latest in Windows presentation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset