Touring the Visual Studio Toolbox


Visual Studio 2005's Toolbox is a far cry from the skimpy tools that shipped with Visual Basic 1.0 back in 1991[4]. It includes a number of new controls, refinements of existing controls, and replacements for others. You might also be disappointed (as I am) that some controls and wizard-launchers are missing from the Toolbox. For example, the shortcuts to the DataAdapter Configuration Wizard and other ADO.NET data access elements have been shelved. In a minute, I'll show you how to re-enable these deprecated data access controls.

[4] You might find Billy Hollis's History of Basic an entertaining overview of how I got here.

By this time, the Visual Studio 2005 Toolbox (shown in Figure 7.1) should be familiar to Visual Basic or C# developers. I've exploded the Data tab to expose the standard set of data-centric controls. Notably missing from the Data tab are the mainstay DataAdapter and other ADO.NET controls we all use so often. It's not hard to bring back these controls, as I'll show you next.

Figure 7.1. The Visual Studio 2005 Windows Forms Toolbox.


Exposing Deprecated Data Access Controls

Microsoft seems to have taken a moralizing stance on some of the new data access features. For reasons only they understand, they have chosen to "hide" some Visual Studio features that many of you have been using from the beginning. For example, every single ADO.NET book, article, or course discusses how to create an updateable DataSet with the DataAdapter Configuration wizard (the DACW). As I said, you won't find this wizard in the Visual Studio 2005 Toolbox. The "Command" and "Connection" wizard icons for each of the providers are gone, toolike the SqlCommand and SqlConnection wizard launchers.

Thankfully, this functionality is still in Visual Studio (for now). I expect they've been hidden because Microsoft doesn't want you to use themor cut yourself while running with scissors. I also expect they want developers to use the new Data Source Configuration wizard and strongly typed DataSet objects. These deprecated items in the Toolbox generated untyped DataSet objects. Many of us still find a number of good ways to use these productivity aidsespecially when teaching folks how to use ADO.NET. Yes, I expect there are still lots of mainstream developers who still depend on them and will miss them as soon as they start using Visual Studio 2005.

Thankfully, it's not hard to add these hidden controls and wizard shortcuts back to the Toolbarjust follow these steps:

1.

Start Visual Studio and create a Windows Forms project. Sure, this can be done in any languageeven C#.

2.

Pin down the Toolbox tab, as you're going to create a new tab.

3.

Right-click below the items in the Toolbox and click "Add Tab". Give your new tab a meaningful name, like "Deprecated Data Components That Microsoft Doesn't Want Me to Use"or perhaps something shorter, like "Untyped Data".

4.

Right-click again in your new tab and select "Choose Items...". This exposes the "Choose Toolbox Items" dialog (after a long wait while it's initialized).

5.

Scroll down to the section for your data access provider. For SQL Server, you'll want to add items from the list of SqlClient components. If you type "S", the pointer moves promptly to the first "S". You can also enter "SqlClient" in the Filter dialog to locate all matching components, as shown in Figure 7.2.



Figure 7.2. The Choose Toolbox Items selector dialog.


6.

Repeat this process for any ODBC and OLE DB components that you want to expose in the Toolbar. When you're done, you should have a new Toolbox tab with the ADO.NET components you've used for the last three versions (as shown in Figure 7.3).

Figure 7.3. The Toolbox with the missing ADO.NET 1.1 components replaced.


Unfortunately, not all of the productivity features we all got used to in earlier versions of Visual Studio are present in Visual Studio 2005 and can't be added back. For example, when you want to create a quick call to a stored procedure and build the Parameters collection, you can (in Visual Studio 2003) drag a stored procedure from the Server Explorer to the Form, and Visual Studio takes care of the rest. Sadly, this does not work in the 2005 version. I understand that one of the new third-party refactoring add-ins can build a Parameters collection from a stored procedure, so all hope is not lost.


Finding the Right Control

One of the problems with having so many controls in the Toolbox is trying to find the one you want. Visual Studio doesn't help much when it comes to locating a specific control, as it supports only ascending or descending alphabetic sorting. However, I find it easiest to simply create your own "MFU" (most frequently used) tabas you choose controls for your project, simply drag the control to your own MFU tab with the Ctrl key held down (to copy the shortcut). Next, use the "Move Up" right-click option to move your custom list to the top of the Toolbox, or simply drag it there.

Before you can access the Toolbox, you'll need to open a Form window.


Understanding the Tool Tray

Some of the controls you'll find in the Toolbox are simply UI elements that expose a graphic on the Windows (or ASP) Form, as well as properties, methods, and events. Others are shortcuts that launch a wizard (like the DACW shortcut I exposed in the previous section). As you well know, to add these controls to your project, you either drag them to the Form or double-click them in the Toolbox. This operation instructs Visual Studio to generate code in Formx.designer.vb/cs. For most (but not all) controls, a visual UI element is placed on the form. For the shortcuts and controls that have no UI elements (such as the Timer, BindingNavigator, and the data access wizards), Visual Studio places an icon in the Form's Tool Tray (below the Form layout area, as shown in Figure 7.4). The icons are also used to set the properties of the controls or restart the wizard that placed them in the Tool Tray. Deleting the icon removes the project code generated to support them. However, it's always a good idea to understand the intercontrol relationships before deleting any cross-dependent control.

Figure 7.4. The Form's Tool Tray populated with several controls.


Tip

You can back out some drag-and-drop operations by deleting selected Tool Tray icons.


All this is basically unchanged from earlier versions of Visual Studio, so let's get to the new stuff.




Hitchhiker's Guide to Visual Studio and SQL Server(c) Best Practice Architectures and Examples
Hitchhikers Guide to Visual Studio and SQL Server: Best Practice Architectures and Examples, 7th Edition (Microsoft Windows Server System Series)
ISBN: 0321243625
EAN: 2147483647
Year: 2006
Pages: 227

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