2. When the app executes, another compiler (known as the just-in-time compiler
2.2 Overview of the Visual Studio Express 2012 IDE
There are several versions of Visual Studio available. Most of this book’s examples are based on theVisual Studio Express 2012 for Windows Desktop. See the Before You Be- gin section that follows the Preface for information on installing the software. Our screen captures and discussions focus on Visual Studio Express 2012 for Windows Desktop. The examples will work on full versions of Visual Studio as well—though some options, menus and instructions might differ. From this point forward, we’ll refer to the Visual Studio Ex- press 2012 for Windows Desktop IDE simply as “Visual Studio” or “the IDE.” We assume that you have some familiarity with Windows.
Introduction to Microsoft Visual Studio Express 2012 for Windows Desktop
We use the>character to indicate the selection of amenu itemfrom amenu. For example, we use the notationFILE > Open File…to indicate that you should select theOpen File…
menu item from theFILEmenu.
To start the IDE, selectStart > All Programs > Microsoft Visual Studio 2012 Express >
VS Express for Desktop(on Windows 8, click theVS for Desktoptile on theStartscreen.
Once the Express Edition begins execution, theStart Pagedisplays (Fig. 2.1). Depending on your version of Visual Studio, yourStart Pagemay look different. TheStart Pagecon- tains a list of links to Visual Studio resources and web-based resources. At any time, you can return to theStart Pageby selectingVIEW > Start Page. [Note:Visual Studio supports both adark theme(with dark window backgrounds and light text) and alight theme(with light window backgrounds and dark text). We use the light theme throughout this book.
The Before You Begin section after the Preface explains how to set this option.]
Links on theStart Page
TheStart Pagelinks are organized into two columns. The left column’sStartsection con- tains options that enable you to start building new apps or to continue working on existing
2.1 Introduction
2.2 Overview of the Visual Studio Express 2012 IDE
2.3 Menu Bar and Toolbar
2.4 Navigating the Visual Studio IDE 2.4.1Solution Explorer
2.4.2Toolbox
2.4.3PropertiesWindow
2.5 Using Help
2.6 Using Visual App Development to Create a Simple App that Displays Text and an Image
2.7 Wrap-Up 2.8 Web Resources
Summary | Terminology | Self-Review Exercises | Answers to Self-Review Exercises | Exercises
2.2 Overview of the Visual Studio Express 2012 IDE 35
ones. TheRecentsection contains links to projects you’ve recently created or modified. You can also create new projects or open existing ones by clicking the links in theStartsection.
The right column contains two tabs—GET STARTED (selected by default) and
LATEST NEWS. The links in theGET STARTEDtab provide information about the pro- gramming languages supported by Visual Studio and various learning resources. An Internet connection is required for the IDE to access most of this information.
TheLATEST NEWS tab includes anEnable RSS Feed button. Once you click this button, the IDE will display links to the latest Visual Studio developments (such as updates and bug fixes) and to information on advanced app-development topics. To access more extensive information on Visual Studio, you can browse theMSDN (Microsoft Developer Network) Library at
The MSDN site contains articles, downloads and tutorials on technologies of interest to Visual Studio developers. You can also browse the web from the IDE by selectingVIEW >
Other Windows > Web Browser.To request a web page, type its URL into the location bar (Fig. 2.2) and press theEnterkey—your computer, of course, must be connected to the Internet. The web page that you wish to view appears as another tab in the IDE (Fig. 2.2).
Fig. 2.1 | Start Pagein Visual Studio Express 2012 for Windows Desktop.
msdn.microsoft.com/en-us/library/default.aspx
Start Pagelinks CollapsedToolboxwindow
Solution Explorer(no projects open) New Projectbutton Start Pagetab
Recent projects will be listed here Latest Newstab
Creating a New Project
To begin app development in Visual C#, you must create a new project or open an existing one. You selectFILE > New Project…to create a new project orFILE > Open Project…to open an existing one. From theStart Page’sStartsection, you can also click the linksNew
Project…orOpen Project…. Aprojectis a group of related files, such as the Visual C# code and any images that might make up an app. Visual Studio organizes apps into projects and solutions, which contain one or more projects. Multiple-project solutions are used to cre- ate large-scale apps. Most apps we create in this book consist of a solution containing a single project.
New ProjectDialog and Project Templates
When you selectFILE > New Project…or click theNew Project…link on theStart Page, theNew Projectdialog(Fig. 2.3) displays.Dialogsare windows that facilitate user–com- puter communication.
Visual Studio provides severaltemplates(Fig. 2.3)—theproject typesusers can create in Visual C# and other languages. The templates include Windows Forms apps, WPF apps and others—full versions of Visual Studio provide many additional templates. In this chapter, you’ll build aWindows Forms Application. AWindowsForms appis an app that executes within a Windows operating system (such as Windows 7 or Windows 8) and typ- ically has agraphical user interface(GUI)—users interact with thisvisualpart of the app.
Windows apps include Microsoft software products like Microsoft Word, Internet Explorer and Visual Studio, software products created by other vendors, and customized software that you and other app developers create. You’ll create many Windows apps in this text.
By default, Visual Studio assigns the nameWindowsFormsApplication1to a newWin-
dows Forms Applicationproject and solution (Fig. 2.3). SelectWindows Forms Application, then clickOKto display the IDE inDesignview(Fig. 2.4), which contains the features that enable you to create an app’s GUI.
Fig. 2.2 | MSDN Libraryweb page in Visual Studio.
Location bar Web browser window tab
2.2 Overview of the Visual Studio Express 2012 IDE 37
Fig. 2.3 | New Projectdialog.
Fig. 2.4 | Designview of the IDE.
Visual C#Windows Forms Application(selected)
Default project name (provided by Visual Studio)
Description of selected project (provided by Visual Studio)
Menu in the
menu bar Form
Properties window Solution
Explorerwindow Active tab
(highlighted in blue)
Forms and Controls
The rectangle in theDesignarea titledForm1(called aForm) represents the main window of the WindowsForms app that you’re creating. Visual C# apps can have multipleForms (windows)—however, most apps you’ll create in this text will use only oneForm. You’ll learn how to customize theFormby adding GUIcontrols—in this example, you’ll add a
Labeland aPictureBox(as you’ll see in Fig. 2.20). ALabeltypically contains descriptive text (for example,"Welcome to Visual C#!"), and aPictureBoxdisplays an image. Visual Studio has many preexisting controls and other components you can use to build and cus- tomize your apps. Many of these controls are discussed and used throughout the book.
Other controls are available from third parties.
In this chapter, you’ll work with preexisting controls from the .NET Framework Class Library. As you place controls on theForm, you’ll be able to modify their properties (dis- cussed in Section 2.4). For example, Fig. 2.5 shows where theForm’s title can be modified and Fig. 2.6 shows a dialog in which a control’s font properties can be modified.
Collectively, theFormand controls make up the app’s GUI. Users enter data into the app by typing at the keyboard, by clicking the mouse buttons and in a variety of other ways. Apps use the GUI to display instructions and other information for users to view.
For example, theNew Projectdialog in Fig. 2.3 presents a GUI where the user clicks the mouse button to select a template type, then inputs a project name from the keyboard (the figure is still showing the default project nameWindowsFormsApplication1 supplied by Visual Studio).
Each open document’s name is listed on a tab. To view a document when multiple documents are open, click its tab. Theactive tab(the tab of the currently displayed doc- ument) is highlighted in blue (for example,Form1.cs [Design]in Fig. 2.4).
Fig. 2.5 | Textbox control for modifying a property in the Visual Studio IDE.
Textbox (displaying the textForm1) which can be modified