Browse DevX
Sign up for e-mail newsletters from DevX


New Features in Visual Studio 2005 Windows Forms : Page 3

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.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

MaskedTextBox Control
Back in the Visual Basic 6 days, when you wanted to make sure users entered data adhering to a specific format, a phone number for example, you used the MaskedEdit control. Prior versions of Visual Studio .NET were missing this capability and that shortcoming has been addressed in Visual Studio 2005. The new MaskedTextBox class, located on the Common Controls section of the Toolbox, derives from the TextBoxBase class and provides the ability to format user data entry. You can set the Mask property manually or you can select from a list of prepared masks accessible by selecting the "Set Mask…" option (see Figure 11) from the smart tag task list (see Figure 12).

Figure 11. Manual Masking: You can create a mask manually.
Figure 12. Selecting Predefined Masks: You can choose from a number of predefined MaskedTextbox input masks.
You can act on a user's invalid keystroke by reacting to the MaskInputRejected event which fires when the input does not match the corresponding mask character in the input mask.

If you want to annoy the users of your application, set the BeepOnError property to True. This will cause the standard error chime to play with each invalid keystroke. You can take advantage of the MaskCompleted property to determine if the user has completed entering data in the MaskedTextBox. The Text property returns the fully formatted value in the control, (515) 123-1234. The InputText property returns the data in the control without the formatting characters; 5151231234, for example.

WebBrowser Control
The new WebBrowser control (System.Windows.Forms.WebBrowser) addresses a number of shortcomings related to adding Web browsing support to Windows .NET 1.0 and 1.1 applications. The WebBrowser control, located on the Common Controls section of the Toolbox, is a wrapper for Internet Explorer and supports printing and saving documents as well as controlling user navigation.

Set the URL property on the control to navigate the user to a specific page. Alternatively, you can call the Navigate method and pass the URL and a Boolean parameter that indicates if a new browser window should be launched. The WebBrowser works asynchronously so your application will not have to wait for the page to finish downloading before continuing.

The ReadyState property tells you if the page has completed loading. You can also code a handler to react to the DocumentCompleted event. The Navigating event fires before navigating to a new page and provides the ability to cancel the navigation if certain conditions have not been met. Set the Cancel property of the WebBrowserNavigatingEventArgs object passed to the event handler to True to cancel the navigation

Private Sub webBrowser1_Navigating( _ ByVal sender As Object, _ ByVal e As WebBrowserNavigatingEventArgs) _ Handles WebBrowser1.Navigating If Now.DayOfWeek = DayOfWeek.Monday Then 'Yes, MsgBox is supported MsgBox("No surfing on Monday!") e.Cancel = True End If End Sub

The Navigated event fires when navigation to a new page has occurred and the page has begun to load. At this point you can begin to access the page content through the Document, DocumentText, and DocumentStream properties.

The AutoComplete feature has been added to the TextBox and ComboBox controls. It provides users of your application with the ability to select from previously entered values. The values displayed are drawn from the user's recent history of activity. The address bar in Internet Explorer provides a perfect example of this feature in action.

Specifying one of three available values (see Table 1) (Suggest, Append, and SuggestAppend) for the AutoCompleteMode property enables the feature for a control.

Table 1:The AutoCompleteMode property supports three options.




Appends the rest of the suggested string to the existing entry. The suggested string appears highlighted.


Displays a drop-down list populated with one or more suggested completion strings. Take note, when working with a ComboBox, the listed values are NOT the values from the Items collection.


Implements both the Suggest and Append options.

The AutoCompleteSource property (see Table 2) controls the type of AutoComplete values displayed.

Table 2: Control where the AutoComplete options are pulled from by selecting one of the options for the AutoCompleteSource




Displays file paths recently used.


Displays URLs from the history list in Internet Explorer.


Displays the files listed in the "My Recent Documents" list.


Displays the URLs from all sites the user visited recently. The list includes URLs entered manually or linked to from another page.


Displays a complete list of URLs and file paths.


Displays directory paths recently used.


Displays the items added to the AutoCompleteCustomSource collection.

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