Windows (WinForms)

Visual Studio provides a mature, feature-rich set of tools for the rapid development of Windows applications that includes a drag-and-drop form designer and many controls inside the form toolbox. With these tools, developers can quickly lay out a Windows application that includes menus, toolbars, data access, tabs, resizing support, common controls for working with and printing files, and much more.

You create a Windows application by selecting the Windows Forms Application project template in the New Project dialog. This type of application is also called a WinForms application because it is based on the WinForms technology in Visual Studio and the .NET Framework.

The first step in a WinForms application is determining the layout of your form. You might decide to create a document-centric application (such as Word or Excel), a single utility application (such as Calculator or Disk Defragmenter), or some other type of application. Whatever your choice, layout is typically controlled through the docking of controls to the form (through the Properties dialog) and the use of Panel controls.

For example, Figure 1.2 shows a possible line-of-business application. A MenuStrip and ToolStrip control are docked to the top of a Windows Form, a StatusStrip is docked to the bottom of the form, and a TreeView and a Tab control occupy the center.

Image

FIGURE 1.2 Building a WinForms application inside Visual Studio 2015.

Containing both the TreeView and the Tab control is a SplitContainer control, which allows two panels to size relative to one another using a splitter bar. Together, these controls define the layout of the main, interactive section of the form. In this case, a user can select records to view in the TreeView control and have a DataGrid within the Tab control automatically populate with the required information. Each control is added to the appropriate area of the form and then configured via the Properties window.

You can start to see that the initial layout and definition of a WinForms application is a rapid experience. You first need to decide your form layout. The tools make it easy from that point forward.

As with all .NET programming, you create the visual design and layout of your user interface and then write code to respond to events. The WinForms application has a standard model that includes such events as Load, Closing, and Closed. You also respond to the events triggered by the controls on the form. For more detailed information about building WinForms applications, see Chapter 20.

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

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