Code Window
As we mentioned, the code window is much like the design window. There is no
toolbox functionality within the code view, however—you cannot drag and drop
objects from the toolbox into the code view. If you create objects in the code
view and then switch back to the design view, the objects that you added would
persist in design view. Again you cannot dock this window nor allow it to float.
You can, however, split it and add new tab groups to the display. Figure 3.5 shows
the code window split and a tab vertical tab order added.
If you look at Figure 3.5 a little more closely, you can see a collapsible menu
tree on the left-hand side. This is created every time you create a class or function,
enabling you to collapse each section independently to save space for viewing
other code present within the window. Note that you must have the default
option Outlining Mode checked for this to work. If you want to have line numbers
show for your code, you will have to choose Tools | Options. In the
Options dialog box, select Text/Editors. Select C# and then choose the option
to have line numbers added.
Figure 3.5 Code View
You may also define your own regions of code that may be collapsed.To do
this simply add the following code to your class or function you want to make
into a region:
#region
///Comments and code
#endregion
Server Explorer
The Server Explorer is by far one of the best features in VS.NET. From this
window you can connect to a server on the network and have full access to that
Server or servers. You can also link to any database servers on the network. Let’s
See how to do that. Click the Connect to Database icon in the title bar of the
Window (see Figure 3.6).You will be prompted to give all information required
for a Universal Data Link (UDL).
Fill out the UDL Wizard and test the connection. After this is done, you can
access everything within that database that the user has rights to. Let’s take a look
at that in Figure 3.7.
Figure 3.6 Add Database to Server Explorer
Figure 3.7 Expanded Database View
You can now click on any object within the Server Explorer and edit it
within VS.NET.This is a timesaver from having to have both the Query Analyzer
and VS.NET open at the same time and going back and forth between the two
just to switch a data type of one stored procedure input parameter.
Toolbox
The Toolbox, shown in Figure 3.8, includes Data, Components, Web Forms, and
Window Forms tabs. As stated earlier in the chapter, you can use the Toolbox
with the Design View window. You can drag and drop each component or control
onto the design window. Also, you may customize the Toolbox by adding in
your own code fragments and renaming them to something meaningful.
To do this, simply right-click on the Toolbox and select Add Tab. Give it a
name that is different than the existing tabs, and you are ready to add your own
tools. To add a new tool, highlight a block of code that you want to make into a
tool and drag it onto the Toolbox label you just created.
The Clipboard Ring stores all the items that you have copied in code view
automatically. You can then double-click these and add them to the source code.
Figure 3.8 The Toolbox Window
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] 下一页