Free computer Tutorials

home
Stay at Home and Learn

Building the Database Form

 
Computer Tutorials List

 

 

 

 

 

If you have Visual Studio and NOT the Visual Basic 2005 Express Edition, your tutorials are here:

Visual Studio .NET and the database Wizard


The first part of the tutorial is here: Database project for Visual Basic 2005 Express users

 

In the previous section, you saw how to open a Data Source. The fields from the database were then available to you in VB .NET. In this part, we'll see how to construct a form so that you can see and scroll through the data.

In the last part, you had the Data Sources window displayed. This one (if you can't see the window, click Data from the menu bar. Then click Show Data Sources):

The Data Sources window

To add a Field to your Form, click on one in the list. Hold down your left mouse button, and drag it over to your form:

Drag a Field to your Form

In the image above, the FirstName field is being dragged on the Form. Notice the mouse cursor has now changed.

When your Field is over the Form, let go of your left mouse button. A textbox and a label will be added. There's two other things to notice: a navigation bar appears at the top of the form, and a lot of strange objects have appeared in the object area at the bottom:

What your form should look like

We'll explore the Objects in a later section. But notice the Navigation bar in blue. Run your programme by hitting the F5 key on your keyboard. You should see this:

The Form is now running

Click the Navigation arrows to scroll through the database.When you've played around with the controls, stop the form from running, and return to Design View.

 

No more reading these lessons online - get the eBook here!

 

Drag and Drop more Fields to your form. But don't align them yet. We'll see an easy way to do this. But once you've dragged the fields to your form, it might look like this:

A very untidy Form

I'm sure you'll agree - that's a very untidy form. But there's a very easy way to align all your controls. Try this:

  • Click on a Textbox with your left mouse button
  • Hold down the Ctrl key on your keyboard, and select a second Textbox
  • With the Ctrl key still held down, click each Textbox in turn
  • When all Textbox are selected, click on the Format menu at the top
  • From the Format menu select Align > Lefts. The left edges of the Textboxes will align themselves
  • From the Format menu select Vertical Spacing > Make Equal. The space between each textbox will then be the same

With your new controls added, and nicely aligned, press F5 to run your form. You might have something like this:

The completed form

Click the Navigation icons to move backwards and forwards through your database.

 

In the next part, you'll move away from the Wizards and learn how to add your own programming code to open up and manipulate databases.

 

Move on to the next part of the VB .NET Database Section -->

<--Back to the .NET Contents Page

View all our Home Study Computer Courses