Tool, Menu, and Status Strips


Jump to: navigation, search
CSharp-Online.NET:Articles
C# Articles

Tool, Menu, Status Strips

© 2006 Matthew MacDonald

This article—Tool, Menu, and Status Strips—is from Pro .NET 2.0 Windows Forms and Custom Controls in C#, by Matthew MacDonald. Copyright © 2006 Matthew MacDonald. All rights reserved. Reproduced by permission. This article has been edited especially for C# Online.NET.  Read the book review! ProNet20Winforms.jpg


Tool, Menu, and Status Strips

.NET 2.0 does something that’s more than a little surprising with its toolbar, status bar, and menu controls—it tosses out the .NET 1.x standbys and replaces them with an entirely new model. The old controls like the ToolBar, StatusBar, and MainMenu are still available (right-click the toolbox and select Choose Items to hunt for them), but they’re intended only for backward compatibility. Now, a new set of classes that includes System.Windows.Forms.ToolStrip and two other derived classes (MenuStrip and StatusStrip) provides a completely new model for toolbars and menus.

The natural question is, Why reinvent the wheel? The legacy ToolBar, StatusBar, and MainMenu classes were based on some of the older corners of the Win32 API, and developers were quick to complain that they were out of place among the slick themed and skinned interfaces popular in modern applications like Microsoft Office. Theming support was entirely absent, which meant that there was no way to harmonize these controls with the Windows XP user interface, and there was no little or no support for reordering buttons, rearranging side-by-side toolbars, or customizing the button-drawing process. In fact, even painting a thumbnail image next to a menu item required custom painting code with the .NET 1.x MainMenu.

For the .NET 2.0 release, the Windows Forms development team was faced with the significant task of bringing these out-of-date controls up to a respectable level. Rather than rework each control separately, they set out to build a new model that could be leveraged for each of these scenarios. That new model revolves around the ToolStrip control. Its many features include a slick modern look, support for themes and customizable rendering, and the ability for the user to drag, rearrange, and customize toolbars effortlessly. In this chapter, you’ll examine the ToolStrip in detail, and use it to create toolbars, status bars, and menus.


Previous_Page_.gif Next_Page_.gif




Personal tools

AbeBooks.com – Textbooks