Chapter 6. Building Windows Forms Applications

 < Day Day Up > 

Topics in This Chapter

  • Introduction: With just a few lines of code, you can build a Windows Forms (WinForms) application that demonstrates the basics of event handling and creating child forms.

  • Using Form Controls: All controls inherit from the base Control class. The members of this class provide a uniform way of positioning, sizing, and modifying a control's appearance.

  • The Form Class: The Form class includes custom properties that affect its appearance, and enable it to work with menus and manage child forms.

  • Message and Dialog Boxes: A pop-up window to provide user interaction or information can be created as a message or dialog box.

  • MDI Forms: A Multiple Document Interface (MDI) is a container that holds child forms. A main menu permits the forms to be organized, accessed, and manipulated.

  • Working with Menus: .NET supports two types of menus: a main form menu and a context menu that can be associated with individual controls.

  • Adding Help to a Form: Help buttons, ToolTips, and HTML Help are options for adding help to a form.

  • Form Inheritance: Visual inheritance enables a form to be created quickly, by inheriting the interface elements and functionality from another form.

This chapter is aimed at developers responsible for creating Graphical User Interface (GUI) applications for the desktop as opposed to applications that run on a Web server or mobile device. The distinction is important because .NET provides separate class libraries for each type of application and groups them into distinct namespaces:

  • System.Windows.Forms. Windows Forms (WinForms).

  • System.Web.UIWebControls. Web Forms.

  • System.Web.UIMobileControls. Mobile Forms for hand-held and pocket devices.

Although this chapter focuses on Windows Forms, it is important to recognize that modern applications increasingly have to support multiple environments. Acknowledging this, .NET strives to present a uniform "look and feel" for applications developed in each. The forms and controls in all three namespaces provide similar, but not identical, functionality. The knowledge you acquire in this chapter will shorten the learning curve required to develop .NET applications for the Web and mobile devices.

Developers usually rely on an Integrated Development Environment (IDE), such as Visual Studio, to develop GUI applications. This makes it easy to overlook the fact that a form is a class that inherits from other classes and has its own properties and methods. To provide a true understanding of forms, this chapter peers beneath the IDE surface at the class members and how their implementation defines and affects the behavior of the form. The discussion includes how to display forms, resize them, make them scrollable or transparent, create inherited forms, and have them react to mouse and keyboard actions.

This is not a chapter about the principles of GUI design, but it does demonstrate how adding amenities, such as Help files and a tab order among controls, improves form usability. Controls, by the way, are discussed only in a generic sense. A detailed look at specific controls is left to Chapter 7, "Windows Forms Controls."

     < Day Day Up > 


    Core C# and  .NET
    Core C# and .NET
    ISBN: 131472275
    EAN: N/A
    Year: 2005
    Pages: 219

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net