Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C# ПІДРУЧНИКИ / c# / Manning - Windows.forms.programming.with.c#.pdf
Скачиваний:
108
Добавлен:
12.02.2016
Размер:
14.98 Mб
Скачать

Do not discount the use of Visual Studio, however. Even relatively modest Windows applications require a number of files and classes to create the resulting program. When working in a text editor, you the programmer must remember the required files, the classes, their member names, and other information. Visual Studio attempts to organize such information on your behalf and alleviates the need to track all of these pieces. In addition, Visual Studio provides some graphical shortcuts intended to ease the layout and programming of your applications. How much they actually help your efforts will depend on your personal preferences. Do, however, take a look and make a conscious decision. As an aside, it is interesting to note that almost all of Visual Studio .NET was written in C#.

Since this book is not specifically about Visual Studio .NET, this is the only chapter that focuses solely on this new environment. Additional information on the environment will be discussed as it arises while building our application, so pay close attention to the procedures shown here. In particular, you should know how to do the following in Visual Studio .NET by the end of this chapter.

Start a new Windows Forms project.

Add and place controls on a form.

Modify properties of a control, including the variable name for the control.

Add a Click event handler to a Button control.

In order to concentrate on the environment, most of this chapter will recreate the photo application already presented in chapter 1. We will call our new program “MyPhotos” and follow the sections from the previous chapter to create a very similar application. This application will be used throughout the rest of the book as we add and refine the features and capabilities of the MyPhotos application.

Lest you get bored, there are some new topics thrown in here as well. In particular, we will look more closely at two topics:

Assembly attributes such as version numbers.

Exception handling in C#.

2.1Programming with Visual Studio .NET

Version 1.1 of the MyForm program was a blank form. A similar application is the default starting point in Visual Studio .NET. In this section we will create an initial MyPhotos application using Visual Studio .NET instead of a text editor. Of course, we are still programming in C#, just using the graphical tools provided by Visual Studio instead of the command-line tools used in chapter 1. In this section we will create a program very similar to that shown in figure 1.1 in the first chapter, on page 4.

As in chapter 1, this discussion assumes you have installed the .NET SDK and Visual Studio .NET on your PC. We also assume you have some knowledge of Windows, such as the ability to start the Visual Studio .NET program. The initial window of this program is shown in figure 2.1.

PROGRAMMING WITH VISUAL STUDIO .NET

35

Соседние файлы в папке c#