The Visual Studio Development Environment
Although the programming language you’ll be learning in this book is Visual Basic, the development environment you’ll be using to write programs is called the Microsoft Visual Studio Integrated Development Environment or IDE for short. Visual Studio is a powerful and customizable programming workshop that abounds in the tools you need to develop robust programs for Windows and the Web quickly and efficiently. Most of the features in the Visual Studio IDE apply equally to Visual Basic, Visual C++, Visual C#, and Visual J#.
The IDE consists of various tools, including a form designer, which allows you to visually create a form; an editor, for entering and modifying program code; a compiler, for translating the Visual Basic statements into the intermediate machine code; a debugger, to help locate and correct program errors; an object browser, to view the available classes, objects, properties, methods, and events; and a Help facility.
In earlier versions of Visual Studio, each language had its own IDE. For example, to create a VB project you would use the VB IDE, and to create a C++ project you would use the C++ IDE. But in Visual Studio .NET, you use the one IDE to create projects in any of the .NET language.
IDE Components:
1. MenuBar
2. ToolBar
3. Design Window
4. Code Window
5. Toolbox
6. Server Explorer
7. Solution Explorer
8. Property Window
9. Output Window
10. Error Window
11. Command Window
MenuBar
File Menu
The File menu contains commands for opening and saving projects, or project items, as well as the commands for adding new or existing items to the current project.
Edit Menu
The Edit menu contains the usual editing commands. Among the commands are the Advanced command and the IntelliSense command.
View Menu
Project Menu
This menu contains commands for adding items to the current project (an item can be a form, a file, a component, even another project). The last option in this menu is the Set As StartUp Project command, which lets you specify which of the projects in a multiproject solution is the startup project (the one that will run when you press F5).
Build Menu
The Build menu contains commands for building (compiling) your project. The two basic commands in this menu are the Build and Rebuild All commands. The Build command compiles (build the executable) of the entire solution, but it doesn’t compile any components of the project that have not changed since the build. The Rebuild All command does the same, but it clears any existing file and builds the solution from scratch.
Debug Menu
This menu contains commands to start or end an application, as well as the basic debugging tools.
Data Menu
This Menu contains command you will use with projects that access data.
Format Menu
The Format menu, which is visible only while you design a Windows or Web form, contains commands for aligning the controls on the form.
Tools Menu
This menu contains a list of tools, and most of them apply to C++. The Macros command of the Tools menu leads to a submenu with commands for creating macros. Just as you can create macros in office application to simplify many tasks, you can create macro to automate many of the repetitive tasks you perform in the IDE.
Architecture
It’s a new tool launched in new IDE. It helps to construct various diagrams such as UML Class Diagram, UML Sequence Diagram, and UML Use Case Diagram . . .etc.
Test
You can create new tests and also edit them. Also you can load meta-data file.
Windows Menu
This is the typical Window menu of any Windows application. In addition to the list of open windows, it also contains the Hide command, which hides all Toolboxes and devotes the entire window of the IDE to the code editor or the Form designer. The Toolboxes don’t disappear completely.
Help Menu
Visual Studio has an extensive Help feature that is generally expanded for .NET. Help includes the Microsoft Developer Network Library (MSDN), which contains reference materials for Visual Basic, C++, C#, and Visual Studio; several books; technical articles; and the Microsoft Knowledge Base, a database of frequently asked questions and their answers.
Help includes the entire reference manual, as well as many coding examples. When you select contents, Index or search from the Help Menu, the requested item appears as another tabbed window on the top of Solution explorer window. Once you select a topic, the corresponding Help page appears in the main Document window.
ToolBar
Toolbar is just like a container for various commands used to perform various tasks while developing applications in Visual Studio 2010. Many of these commands are the shortcuts to the options present in the various menus of the menu bar. The commands present in the Toolbar include commands for creating a new project, opening an existing project, and saving a project. Figure shows the Toolbar with the various commands added to it.
Design Window
It is the central to developing an application in Visual Studio 2010 that occupies the middle portion of the IDE. It is the place where we can design the interface for a form by adding and organizing controls on the Form. You can open the Design window of a Form by double clicking on the name of the form in the Solution Explorer. The Design window of form is shown in Figure.
Code Window
It is the place where we write all the business logic in form of code. We generally write event handlers in the Code window. Event handlers are the methods, which tell the computer how to respond when an event occurs. For example, we can open a message box displaying a message, when the user clicks on a button added to a Form. Figure shows the Code window of Form1. If code window of a Form is not opened, you can open it using the following ways:
· By right-clicking on the name of the Form in the Solution Explorer and selecting the View Code option from the context menu that appears.
· By double-clicking on the Form or any control added to the Form in the design view of the Form.
· By Selecting the name of the Form in the Solution Explorer and pressing the F7 key from the keyboard.
ToolBox
It is generally present at the left side of the Design window in the Visual Studio 2010 IDE. It is a collection of controls, which we use while designing the user interface for a Form, which is added to an application. The controls in the Toolbox are grouped under different tabs, such as Common Controls, Menus & Toolbars, and Data Tab. Each tab stores controls related to a specific category. For example, the Data tab stores the controls, which are used in the applications that require interaction with databases. You can open the Toolbox by selecting the Toolbox option from the View menu or by pressing the Ctrl + Alt + X key combination from the keyboard. Figure shows the Toolbox displaying its various tabs.
Sometimes tools are classified as per process also:
· Entry level tool = textbox, richtextbox . . .etc.
· Selection level tool = radio button, checkbox, command button . . .etc.
· Items selection tool = listbox, combobox.
· Special tool = list view, treeview, scrollbar . . .etc.
· Group level tool = groupbox, panel, datagrid . . .etc.
Server Explorer
Server Explorer is mainly used for connecting an application to the database server. We create data connection using the Server Explorer for connecting to the database server. While creating a data connection for connecting to a database server, we can specify the name of the database that we want to use in our application. It will add the specified database, along with all the tables it contains, in the Server Explorer. We can use the data contained in these tables in our application and also make changes in the table data using Server Explorer. You can open the Server Explorer by selecting the Server Explorer option from the View menu or by pressing the Ctrl + Alt + S key combination from the keyboard. Figure shows the Server Explorer with a data connection added to it.
Here are some of the tasks you can perform using the Server Explorer which are as follows:
· You can open the data connections and commands.
· You can log on to servers, display their databases and system services, including event logs, message queue, performance counters, system services, and SQL databases.
· You can view information about available Web services and the methods and schemas that they make available.
· You can store database projects and references.
· You can drag notes from Server Explorer into Visual Studio projects, thus creating data components that reference the data resource or monitor its activity.
· You can interact with the data resources by programming to these data components created in your Visual Studio projects.
Solution Explorer
It enables us to view the solution we are working with, all the projects that it contains, and Forms and other items added to each project. By default, Solution Explorer do not show all the files included in a solution. You can make all of them displayed in it by pressing the Show All Files button, which is the second button in the toolbar of the Solution Explorer. You can open it by selecting Solution Explorer option from the View menu or by pressing the Ctrl + Alt + L key combination from the keyboard. Figure shows a solution, a project included in the solution, and all the items that the project abounds in.
The first button present in the toolbar of the Solution Explorer can be used to view or set the properties of the items added to a project in the Properties window. You can do so by selecting that item in the Solution Explorer and clicking on the first button in the toolbar of the Solution Explorer. You can also use the View Code and View Designer buttons present in the toolbar of the Solution Explorer to switch between the Design window and Code window of a Form.
Buttons in the Solution Explorer:
· Properties – Opens the Properties window which is used to display the properties of the selected file or control.
· Show all files – Displays all the files along with any code-behind files in the Solution Explorer.
· Refresh – Refresh the Solution Explorer.
· View Code – Displays the selected file in the Code Editor.
· View Designer – Displays the designer for the selected file in the Solution Explorer.
· View Class Diagram – Opens the Class Designer and displays the overall class details such as methods, events, fields, and properties.
Properties Window
It enables us to view as well as set properties of a solution, projects included in the solution, and various controls we are using in our application. It is also used to view or set events of a Form or controls added to the Form. Figure shows the Properties window displaying properties of Form1. You can open the Properties window using any of the following ways:
· By selecting the Properties Window option from the View menu.
· By pressing the F4 key from the keyboard.
· By right-clicking on an item added to a project and selecting the Properties option from the context menu that appears.
· By right-clicking on the opened Form or any control added to the Form and selecting the Properties option from the context menu that appears.
You can notice in Figure that the properties displayed in the Properties window are grouped under different categories, such as Appearance, Behavior, Data, and Design. You can sort them in alphabetic order by clicking on the second button present in the toolbar of the Properties window. You can also select some other item from the drop-down list present above the toolbar of the Properties window to display its properties or events in the Properties window. Just as displaying properties of an item in the Properties window, you can also display events of an item in it by clicking on the button lightening sign in the toolbar of the Properties window.
The Properties window also displays a toolbar containing various buttons. These buttons are explained, starting from left to right, as follows:
· Categorized – Enables you to group the properties for a control into categories. For example, when you select a form in the Solution Explorer window and click the Categorized button on the toolbar, the Form properties are grouped into Accessibility, Appearance, Behavior, Data, Design, Focus, Layout, Misc, and Windows Style categories.
· Alphabetical – Arranges the properties of a control alphabetically.
· Properties – Displays the properties of a control.
· Events – Displays various events of a control.
· Property Pages – Display the Property Pages dialog box for the selected component. You can use the Property Pages dialog box to view and edit the properties related to the configuration of the Project.
Output Window (Ctrl + Alt + O)
The output window is where many of the tools, including the compiler, send their output. Every time you start an application, a series of messages are displayed on the Output window. These all messages are generated by the compiler. If the Output window is not visible, select the View | Other Windows | Output command from the menu.
You can also send output to this window from within your code with the console.writeline method. Actually, this is a widely used debugging technique – to print the values of certain variables before entering a problematic area of the code. To demonstrate the use of output window, type,
console.writeline(“amit”)
in any button’s procedure on form. Run your application, and press button (that you have placed on the form) to execute the above code, and then click on close button of the form. Now you can see the output of your application in the output window as shown in below diagram.
The various tabs functions used in the Output window are described as follows:
· Build – Displays progress and error messages from the compiler and linker.
· Debug – Displays output from the debugger.
You can see various buttons available on the Output window toolbar. Here is the description of these buttons:
· Show Output from – Allows one or more output panes to view that might be available, depending upon which tools in the IDE have used the Output Window. For example, when you run your application, it shows the output for build and if any error occurs then it will show the output for debugging. You can select either the Build or Debug option from the Show Output from drop-down list.
· Find Message in Code – Moves the insertion point to the line Code Editor to the line that contains the selected build error in the code Editor.
· Go to the Previous Message – Moves the insertion point in the Code Editor to the line that contains the previous build error.
· Go to the Next Message – Moves the insertion point in the Code Editor to the line that contains the next build error.
· Clear All – Removes all texts from the Output pane.
· Toggle Word Wrap – Toggle the Word Wrap feature on and off in the Output pane. When turned on, the text that extends from the viewing area is displayed on the line that follows it.
Command Window
While testing a program, you can interrupt its execution by inserting a breakpoint. When the break point is reached, the program’s execution is suspended and you can execute a statement in the command window. Any statement that appears in your VB code can also be executed in the command window.
Error Task List Window
This window is usually populated by the compiler with error messages, if the code can’t be successfully compiled. You can double-click an error message in this window, and the IDE will take you to the line with the statement in error – which you should fix.
You can also add your own tasks to this window. Just click the first empty line and start typing. A task can be anything, from comments and reminders, to the URLs to interesting sites. If you add tasks to the list, you are responsible for removing them. Errors are removed automatically as soon as you fix the statement that caused them.
The Error List toolbar consists of the following tabs:
· Errors – Display the number of errors in the list.
· Warnings – Displays the number of warnings in the list.
· Messages – Displays the number of messages in the list.












Comments
Post a Comment