Home > Articles

  • Print
  • + Share This

Controls Added to the Toolbox

Okay, time to take a break from all the things you should know before you start creating your application. One neat thing about installing a new version of a development tool such as Visual Basic is seeing what new "stuff" has been added. Although most controls in Visual Basic have stayed pretty much the same, some additions should be mentioned before you get into the nitty-gritty of application building. All these controls are available only in the Professional and Enterprise editions of Visual Basic. In the last section of today's lesson, you'll see how to combine several of these controls with others available in Visual Basic to create more complex interactions with your application's users.

LinkLabel

The LinkLabel control allows you to display text on a form in hyperlink format (see Figure 1.16) and provides you with the capability to link to another window in the application, or to a Web site. The actual linking action is accomplished with the control's LinkClicked event routine.

Figure 1.16 Using the new LinkLabel control to display a Web site hyperlink and take the user to that site when clicked.

Listing 1.3 shows the code needed to actually perform the link, using a new object or namespace, System.Diagnostics. This namespace provides a method and command, Process.Start, which will actually start the default Internet browser passing the URL in the LinkLabel's Text property.

Listing 1.3[em]Using the LinkLabel Control in Visual Basic.NET

Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, _
 ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) _
 Handles LinkLabel1.LinkClicked
 LinkLabel1.LinkVisited = True
 ' Call the Process.Start method to open the default browser
 ' with a URL:
 System.Diagnostics.Process.Start(LinkLabel1.Text)

End Sub

NotifyIcon

In previous releases of Visual Basic, if you wanted to include a system tray icon in your application, you needed to use some sample code that provided you with the capability to interact with the system tray. However, the actual code was nothing but sample code that you needed to modify. In Visual Basic.NET, the use of the system tray has become part of the language. The new NotifyIcon control (see Figure 1.17) provides you with the capability to display an icon in the Windows System Tray. By using this control in conjunction with the new Context Menu control, you can create sophisticated access to your application from the system tray.

Figure 1.17 The NotifyIcon can display a context menu with several options from the application.

Error Provider

The Error Provider control provides you with a simple way to tell the user that a control has an error associated with it. When this control is added to the form, all other controls on the form will have a new property added to them. This new property, Error on ErrorProvider, displays an error to the user (see Figure 1.18). Setting the property to a string, which indicates the error, does this. Once this is done, an icon is displayed next to the control in question. The user needs only to move the mouse over the icon to have the error message displayed.

Figure 1.18 Using the Error Provider to display a control's associated error message.

ToolTip

Some controls available to you in Visual Basic have a tool tip property that allows you to display a string to the user when the mouse is moved onto the control. However, many controls don't have a tool tip property. The ToolTip control, when added to a form, will add a tool tip property to all other controls on the form. Then, the only thing you need to do for the tool tip to be displayed is set the new property for the required controls.

Controls that Changed

As in most releases of Visual Basic, many changes have been made to existing controls and features. Although there are too many to mention in this section, two major changes should be mentioned. The first is the change of the single Common Dialog control into individual controls for each common function (discussed on Day 2, "The Face of a Windows Application"). The second is the elimination of the Menu Editor. Rather than have a separate editor to create menus for a form, you can now add the MainMenu control to the form and perform the creation directly on the form as discussed on Day 3, "Creating Simple Forms." There's also now a separate ContextMenu control that provides pop-up menu functionality.

Some other controls that have been modified are

Tab Replaces the Tab and Tabstrip controls
RadioButton Replaces the Option Button
CheckedListBox New in this release
DateTimePicker Replaces the DTPicker control
GroupBox and Panel Replaces the Frame control

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.