Visual Studio 2010!

Read now >

View Now
DevSource RSS FEEDS
XML Want an easy way to keep up with breaking tech news? And the Get DevSource headlines delivered to your desktop with RSS.
ADVERTISEMENT
ADVERTISEMENT

 

DevSource.com: Your Source for Visual Studio on Facebook
ADVERTISEMENT
A Tour of ToolStrips in Windows Forms
By John Mueller

Rate This Article: Add This Article To:

A Tour of ToolStrips in Windows Forms - ' Databases Made Easy '
( Page 4 of 4 )

Databases Made Easy

I recently spend the better part of two weeks playing with the new features in Visual Basic. I'm assuming Visual C# also suffers from the riches of new database features that I found. By creating the right stored procedures on the server, I could drag-and-drop my way to some very complex database applications. Sure, I had to supply some glue code, but creating a database application is no longer as much of a pain. The BindingNavigator and DataNavigator controls come free with the new drag-and-drop database functionality that Microsoft is promoting.

I'm not going to bore you with all of the details of creating your own database application, but it's helpful to look at one to see what Microsoft has done with ToolStrip control technology.

When you work with the new setup, you begin by creating a data source for your database application. From there, you can choose the overall presentation of the data and the format of the individual fields within the display. One of the two common presentations is the GridView, shown in Figure 6.

Figure 6: Working with databases shows you some interesting uses for ToolStrip technology.

The Visual Studio IDE created all of this automatically. The application is functional, and I didn't write a single line for code. The top toolbar is a ToolStrip that shows yet one more use for that Label, TextBox, and Button combination I told you about earlier. The user fills out customer identifiers, and clicks Fill to obtain that customer's order history. The buttons on the BindingNavigator (the second toolbar) fills out the functionality by letting you move from record to record.

Look again at Figure 6 and you'll notice that both toolbars have a similar appearance; you work with them using the same techniques. The same Items Collection Editor that you use to edit every other ToolStrip control works for these toolbars, too. In short, one of the best features of this latest version of Visual Studio is that you use a consistent technique to edit all of the controls.

An unfortunate feature (or lack thereof) of the ToolStrip control is that it doesn't provide any form of automatic docking or dragging. Considering that this is going to be very common code, I had expected that Microsoft would include it as part of the control. Consequently, if you want someone to be able to dock or drag the ToolStrip around, you need to add code to it. Interestingly enough, Microsoft even places the code you need in the help file. Check out the Docking Windows Sample as one example. You'll also want to try the ToolStrip Customizing Sample.

Controls in a Container

As applications become more complex, some developers are turning to new ways of organizing controls so that the user doesn't have to work with many of them at one time. The ToolStripContainer helps you organize controls in a way that reduces complexity, yet makes everything available to the user.

The ToolStripContainer is a management tool of sorts. When you place one of these controls on a form, you see four outside panels and a content panel in the center. The outside panels are where you place MenuStrip, StatusStrip, or ToolStrip controls. You can hide everything in a panel by setting that panel's Visible property to False. In short, you obtain an effect not unlike the IDE setup for Visual Studio. You can dock things to a panel, make the panel appear and disappear as needed, and provide content in the center of the form with relative ease.

ToolStrips are one of the more interesting and useful features of Visual Studio 2005. You'll use them to create applications with better user interfaces that reduce both development and support costs. However, it always seems as if Microsoft never takes that last step. Besides the code you need to write to make your application functional, you'll also find that you'll write a lot of code to make the ToolStrip and its derived controls functional. Microsoft has done a wonderful job of creating the visual elements of these new controls, but they didn't quite complete the part that really matters: the internal workings.



 
 
>>> More Using Microsoft Visual Studio Articles          >>> More By John Mueller