Microsoft Visual Basic 2010 Step by Step eBook

(Tina Meador) #1

Chapter 18 Getting Started with ADO .NET 459


country to country, but for me it looks like a North American telephone number with
area code .)


  1. Add a label object in front of the new masked text box object, and set its Text property
    to “Phone:” (including the colon).
    The first descriptive label was added automatically by the Data Sources window, but we
    need to add this one manually.

  2. Adjust the spacing between the two labels and text boxes so that they are aligned
    consistently. When you’re finished, your form looks similar to the following:


Now you’ll bind the Business Phone field in Faculty2010DataSet to the new masked text
box object. The process is easy—you simply drag the Business Phone field from the
Data Sources window onto the object that you want to bind to the data—in this case,
the MaskedTextBox1 object.


  1. Display the Data Sources window if it is not visible, and then drag the Business Phone
    field onto the MaskedTextBox1 object.
    When you drag a dataset object onto an object that already exists on the form
    (what we might call the target object), a new bound object is not created. Instead,
    the DataBindings properties for the target object are set to match the dragged
    dataset object in the Data Sources window.
    After this drag-and-drop operation, the masked text box object is bound to the
    Business Phone field, and the masked text box object’s Text property contains a small
    database icon in the Properties window (a sign that the object is bound to a dataset).

  2. Verify that the MaskedTextBox1 object is selected on the form, and then press F4 to
    highlight the Properties window.

  3. Scroll to the DataBindings category within the Properties window, and then click the
    arrow to expand it.

Free download pdf