Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


New Features in Visual Studio 2005 Windows Forms : Page 2

Updated IDE features, new Menu, Toolstrip and multimedia controls, support for background threading, and a new deployment technology called ClickOnce aimed squarely at reducing the number of Web-based intranet applications are among the new capabilities in Visual Studio 2005.

ToolStrip Control
The new ToolStrip class (System.Windows.Forms.ToolStrip) located in the Menus & Toolbars section of the Toolbox, replaces the out-of-date ToolBar class and supports a variety of ToolStrip widgets including the ToolStripButton, ToolStripSplitButton, ToolStripDropDownButton, Button,ToolStripLabel, ToolStripProgressBar, ToolStripSeparator, ToolStripCombobox, and ToolStripTextBox. A ToolStrip appears with a modern, Office-style, flat look and supports Windows XP Themes.

Figure 4. Docking the ToolStrip: You can dock the ToolStrip in a variety of locations.
Figure 5. ToolStrip Hosting: The ToolStrip control can host a number of different types of controls.
Figure 6. Managing ToolStrip Controls: The Items Collection Editor manages the controls to a ToolStrip.
You can position the ToolStrip by selecting its Dock property and clicking on the position indicator (see Figure 4). You can add items to a ToolStrip in a variety of ways. Clicking on the "AddToolStrip" button tool located in the ToolStrip will add a ToolStrip button while clicking the down arrow provides the ability to select one of a number of different ToolStrip controls (see Figure 5). Selecting the ToolStrip's smart tag and selecting Edit Items is another technique for adding items to the ToolStrip. The Items Collection Editor (see Figure 6) provides the ability to add new ToolStrip items and/or manage the properties of existing ToolStrip items. Selecting "Insert Standard Items…" from the smart tag menu automatically adds standard buttons for document management (New, Open, Save, Print, Cut, Copy, Paste, and Help).

All ToolStrip items derive from the ToolStripItem class and support properties such as Text, Image, ImageAlign, Enabled, and Visible. Unlike the legacy ToolBar control which fired an event at the control level when clicked, each button on a ToolStrip control supports its own Click event.

Private Sub ToolStripButton1_Click( _ ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles ToolStripButton1.Click MessageBox.Show("Click for the Button") End Sub

You will not find the legacy ToolBar control in the ToolBox. It, along with controls like the StatusBar (which is replaced by the StatusStrip control), have been left out of the ToolBox; however, if you want to re-add any of the legacy controls, right-click on the ToolBox, select Choose Items, and pick the controls you wanted added from the list.

Figure 7. StatusStrip: The StatusStrip supports a number of different rendering modes.
StatusStrip Control
The new StatusStrip class (System.Windows.Forms.StatusStrip) located in the Menus & Toolbars section of the Toolbox derives from the ToolStrip class and replaces the legacy StatusBar class. It supports a variety of ToolStrip items such as ToolStripStatusLabel, ToolStripProgressBar, ToolStripDropDownButton and ToolStripSplitButton. Like the ToolStrip control, it appears with a modern, Office-style, flat look and supports Windows XP Themes (see Figure 7). Deriving from the ToolStrip, the StatusStrip shares many of the same features, UI elements, and capabilities as the ToolStrip such as each StatusStrip item supporting its own Click event.

MenuStrip Control
The new MenuStrip class (System.Windows.Forms.MenuStrip) located in the Menus & Toolbars section of the Toolbox also derives from the ToolStrip class and replaces the legacy MainMenu control. It supports a variety of ToolStripMenu items including ToolStripMenuItem, ToolStripComboBox, and ToolStripTextBox. Each ToolStripMenuItem object supports a number of welcome properties including Image, ToolTipText, and Font manipulation.

Figure 8. MenuStrip Control Management: The ToolStrip Items Collection Editor manages controls on a MenuStrip.
Figure 9. Automatic Common Menus: Common menu options such as File, Edit, and Help can be automatically added using the Insert Standard Items Smart Tag option.
Figure 10. Adding ContextMenu Items: ContextMenu items are assigned to a control using the ContextMenuStrip property.
You add menu items in one of three ways. First, like the legacy MainMenu control, you can create and edit menus manually by typing the prompts directly into the menu. The second approach is to select "Edit Items…" from the smart tag task list and then work with the Items Collection Editor (see Figure 8). The third and most efficient approach is to select "Insert Standard Items" from the smart tag task list to automatically populate your menu with a complete menu that includes File, Edit, Tools, and Help items (see Figure 9).

ContextMenuStrip Control
The new ContextMenuStrip class (System.Windows.Forms.ContextMenuStrip) located in the "Menus & Toolbars" section of the Toolbox derives from the ToolStripDropDown class and replaces the legacy ContextMenu class. Implementing this class works much the same way as the legacy ContextMenu class worked. You construct a ContextMenuStrip and assign it to the ContextMenuStrip property for a control (see Figure 10). When the user right-clicks on the control, the ContextMenuStrip menu appears.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date