C# 24-Hour Trainer. Stephens Rod

Чтение книги онлайн.

Читать онлайн книгу C# 24-Hour Trainer - Stephens Rod страница 9

C# 24-Hour Trainer - Stephens Rod

Скачать книгу

the Charms area, click Search, and type VS Express (or part of the name of the version you installed). If Visual Studio isn't in the result list, make sure the search box's dropdown list has Everywhere selected.

      b. In the search results, right-click the program and select Pin to Start or Pin to Taskbar.

      2. Launch Visual Studio by clicking the tile you just pinned to the start screen or the icon you just pinned to the taskbar.

      3. Create a new project.

      a. Press Ctrl+Shift+N or open the IDE's File menu, expand the New submenu, and select Project.

      b. Expand the Visual C# project types folder and select the Windows Forms Application template.

      c. Enter a project name and a good, easy-to-find location like the desktop or a folder named C# Projects on the desktop.

      d. Uncheck the Create Directory for Solution box.

      e. Click OK.

      ● Experiment with the IDE's layout by displaying the Debug toolbar, pinning the Toolbox, and displaying the Output window.

      1. Open the Tools menu and select Customize. On the Customize dialog, select the Toolbars tab and check the box next to the Debug toolbar. Experiment with the other toolbars if you like. Close the dialog when you're done.

      2. If the Toolbox is auto-hiding (it should be after you first install Visual Studio), float the mouse over it until it expands. Click the thumbtack to pin it.

      3. To display the Output window, open the View menu and select Output. Grab the Output window's title bar and drag it around. Move it over some drop targets to see where it lands. When you're finished, drop it at the bottom of the IDE as shown in Figure 1.7.

      ● Run the program.

      1. Press F5 or open the Debug menu and select Start Debugging.

      2. Try out the form's minimize, maximize, and close buttons and the commands in the form's system menu. Move the form around and resize it. Marvel at the fact that you didn't need to write any code!

      ● Find the program's executable, copy it to the desktop, and run it there.

      1. Start File Explorer and navigate to the location that you specified when you created the new program.

      2. There you should find a folder named after the program. Open that folder and examine the files inside. Notice the .sln file that you can double-click to reopen the solution in Visual Studio. Notice also the bin, obj, and .vs directories.

      3. Enter the bin directory and move into its Debug subdirectory. It contains several files including the executable, named after the program but with the .exe extension. Right-click the executable and select Copy.

      4. Right-click the desktop and select Paste to copy the executable to the desktop.

      5. Double-click the copy of the executable on the desktop.

      ● Copy the project folder to a new location and make changes to the copy.

      1. In File Explorer, go to the directory that contains the project folder.

      2. Right-click the project's folder and select Copy.

      3. Right-click the desktop and select Paste to copy the project folder.

      4. Open the copied project folder and double-click the .sln file to open the copied project in Visual Studio. If the form doesn't open in the Form Designer (#4 in Figure 1.7), look in Solution Explorer and double-click the file Form1.cs.

      5. In the Form Designer, grab the handle on the form's lower-right corner and resize the form to make it tall and skinny.

      6. Run the modified program. Then go back to the original project (which should still be running in another instance of Visual Studio) and run it. Notice that the two versions display forms of different sizes.

      ● Compress the project folder to make a backup.

      1. In Visual Studio, close the project. (Or close Visual Studio.)

      2. In File Explorer, return to the project's folder and delete the bin, obj, and .vs directories. (Note that you can't delete the bin directory if Visual Studio has the project open.)

      3. Move up one level to the directory that contains the project folder. Right-click the folder, expand the Send To submenu, and select Compressed (Zipped) Folder.

      4. E-mail copies of your first project to all of your friends and relatives. I'm sure they'll thank you!

      Exercises

      1. Build a solution that contains two projects. (Create a project named Project1. Check the Create Directory for Solution box and name the solution TwoProjects. Then open the File menu, expand the Add submenu, and select New Project to add a new project named Project2.)

      2. This lesson explains only a tiny fraction of the ways you can customize Visual Studio. Try another one by making your own toolbar. Select the Tools menu's Customize command. On the Toolbars tab, click the New button, and name the new toolbar MyTools. On the Commands tab, select the Toolbar radio button and then select the new toolbar from the dropdown list. Now use the Add Commands button to add some commands to the toolbar.

      3. This lesson also describes only a few of the windows Visual Studio offers. Use the menus to find and display the Output, Immediate, Error List, and Task List windows. Put them all in tabs at the bottom of Visual Studio (#8 in Figure 1.7).

      4. Some tools are available only when Visual Studio is in a certain state. Look in the Debug menu's Windows submenu. Then start the program and look there again. Most of those windows are useful only when the program is running and you are debugging it. (I talk about some of them in later lessons.)

      5. [WPF] Create a new WPF application. Run it side by side with a Windows Forms application. What are the differences? (Hint: There shouldn't be many and they should be cosmetic. You learn about more important but less obvious differences in later lessons.)

      NOTE

      Please select the videos for Lesson 1 online at www.wrox.com/go/csharp24hourtrainer2evideos.

      Lesson 2

      Creating Controls

      Way back in the computer stone ages, when programmers worked by candlelight on treadle-powered computers and hand-carved wooden monitors, input and output were very simple. The computer wrote text in toxic green on the bottom of a monitor and the text scrolled up as the monitor became full. The user typed on a keyboard to enter text at a single input prompt, and that was about it. Multiple windows performing useful work simultaneously, mice, and forms displaying many labels and textboxes, buttons, scrollbars, and full-color images existed only in the fevered dreams of science-fiction writers.

      Today these things are so commonplace that we take them completely for granted. They appear

Скачать книгу