Datasheet

You can execute much more complex statements in the Command and Immediate windows. For example,
suppose that your program uses the following statement to open a file for reading.
Dim fs As FileStream = File.OpenRead( _
“C:\Program Files\Customer Orders\Summary” & _
datetime.Now().ToString(“yymmdd”) & “.dat”)
Suppose that the program is failing because some other part of the program is deleting the file. You can
type the following code (all on one line) into the Immediate window to see if the file exists. As you step
through different pieces of the code, you can use this statement again to see if the file has been deleted.
?System.IO.File.Exists(“C:\Program Files\Customer Orders\Summary” & _
DateTime.Now().ToString(“yymmdd”) & “.dat”)
The window evaluates the complicated string expression to produce a file name. It then uses the
System.IO.File.Exists command to determine whether the file exists and displays True or
False accordingly.
Data
The Data menu, shown in Figure 1-34, contains commands that deal with data and data sources. Some
of the commands in this menu are only visible and enabled if you are designing a form and that form
contains the proper data objects.
The following list describes commands shown in Figure 1-34:
❑ Show Data Sources — This command displays the Data Sources window, where you can work
with the program’s data sources. For example, you can drag and drop tables and fields from this
window onto a form to create controls bound to the data.
❑ Preview Data — This command displays a dialog box that lets you load data into a
DataSet
and view it at design time.
❑ Add New Data Source — This command displays the Data Source Configuration Wizard,
which walks you through the process of adding a data source to the project.
❑ Add Query — This command is available when you are designing a form and have selected a
data bound control such as a
DataGridView or bound TextBox. This command opens a dialog
where you can specify a query to add to the form. This places a
ToolStrip on the form contain-
ing
ToolStripButtons that populate the bound control by executing the query.
Format
The Format menu, shown in Figure 1-35, contains commands that arrange controls on a form. The fol-
lowing list describes the Format menu’s submenus:
❑ Align — This submenu contains commands that align the controls you have selected in various
ways. It contains the commands Lefts, Centers, Rights, Tops, Middles, Bottoms, and to Grid.
For example, the Lefts command aligns the controls so their left edges line up nicely. The to
Grid command snaps the controls to the nearest grid position. This is useful if you have moved
some controls off of the alignment grid, possibly by using one of the other Align commands or
by changing a control’s Location property in the Properties window.
34
Part I: Getting Started
37055c016.qxd 4/8/07 12:46 PM Page 34