he little voice in my head shouted "Don't do it! Don't do it!" as I contemplated using the worn out cliché "Good things come to those who wait" to describe the experience of designing Windows applications with Visual Studio 2005.
However, that cliché accurately communicates the idea that building Windows Forms applications in Visual Studio 2005 is better, makes you more productive, and is more fun than doing the same task in Visual Studio 2003, not to mention VB6!
Part of what makes working with Windows Forms so exciting these days is Microsoft's renewed emphasis on smart client development. It is no secret that Windows applications provide a richer and better user experience than Web-based applications. Web-based applications have had the upper hand primarily because they are easier to deploy. For years now, IT departments have been willing to sacrifice the user experience in order to take advantage of the deployment advantages offered by Web-based applications.
Microsoft has addressed the Windows application deployment issue with the new ClickOnce technology introduced with Visual Studio 2005. Of course Web-based applications will always have their place on the Internet, but I think the pendulum is about to swing back in favor of developing rich, user-centric, Windows applications for internal corporate applications.
|Figure 1. Toolbox Sections: The Toolbox is organized into sections.|
This article touches on some of the new enhancements made to the Visual Studio Integrated Development Environment (IDE), new controls, and new components. I chose to code the samples in Visual Basic and I am sure that will not adversely hamper a C# programmer from learning about the new Windows Form features in Visual Studio 2005.
Visual Studio 2005 IDE Features
|I think the pendulum is about to swing back in favor of developing rich, user-centric, Windows applications for internal corporate applications.|
The Visual Studio IDE and Windows Form teams have been busy adding or improving features that increase your productivity. A reorganized Toolbox will be one of the things you notice when you create your first Visual Studio 2005 Windows Form application. Controls are grouped according to function into categories including Common Controls, Containers, Menus & Toolbars, and Data, to name a few (see Figure 1
The new snap lines feature will be the next feature you notice. This feature provides visual confirmation that controls are horizontally or vertically aligned (see Figure 2). This will save you time because you will never have to set Left or Top properties or use the Format --> Align menu option to ensure controls are lined up correctly.
|Figure 2. Aligning Controls: Lining up controls is much easier with the new snap lines feature.|
Drop a Textbox control on a form, select it, and you will see a small smart tag arrow in the upper right corner of the control. Clicking this arrow displays the Textbox Tasks dialog box which provides a list of the common operations performed on the control (see Figure 3
|Figure 3. Smart Tags: With smart tags common options are just a click away.|
I could go on and on about additional enhancements made to the Visual Studio development environment and project structure, but I will leave that for another article. For now, I will move on to specific Windows Form enhancements.
Working with Data
One of the goals for Visual Studio 2005 was to simplify the process of retrieving and binding data to form controls. Two new IDE features have been added-the Data Sources window and the Data Source Configuration Wizard.
Data sources represent the data that you want to work with in your application and are listed in the Data Sources window. As you would expect, your can make data sources from databases, but you can also create them from Web services and business objects. You add data-bound controls to your forms by dragging items from the Data Sources window. Each item in the Data Sources window provides you with a list to select the type of control to create prior to dragging it onto a form.
|The new snap lines feature provides visual confirmation that controls are horizontally or vertically aligned.|
It's no secret that the DataGrid control in Visual Studio 2003 was fairly limited, difficult to customize, tough to extend, and was nearly almost universally shunned in favor or more powerful and flexible third-party controls. Trying to fix the problems in the DataGrid, while keeping it backward compatible, proved to be a nearly impossible task. The Windows Forms team decided to go back to the drawing board and design a completely new and better grid control, the DataGridView control.