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

TRY IT! Modify the order in which the controls are added to the form (add the PictureBox first and the Button second) to change the z-order of the button and box. This will cause the button to be below (or behind) the image so that it no longer appears. However, the button is still there, and you can use the access key Alt+L to load an image.

While you are at it, try setting the Dock property for the Button to DockStyle.Top. How does this affect the application window, and how does the z-order for these controls affect their placement on the form?

Of course, you can experiment with other Dock settings as well.

We will use the Dock and Anchor properties throughout the book, so more examples with these properties are yet to come.

1.5Recap

Before we move on, let’s quickly review what we covered in this chapter. These chapter recaps will be quick, and will introduce the subsequent chapter as well.

In this chapter we did a whirlwind tour of .NET terms and C# features. We showed how to build and run an application containing a blank form, and added a Load button to select an image file and a picture box control to display this file. We discussed different members of C# classes such as constructors, methods, properties, and events, and saw how .NET executes a program. We also looked at how to use the OpenFileDialog class to open a file, and the Anchor and Dock properties for setting the position and resize behavior of a control.

We intentionally ignored Visual Studio .NET in this chapter. Instead we edited code by hand and used the command-line compiler to build and link our program. In the next chapter we will examine how to build the identical program using Visual Studio .NET, and use the opportunity to present some additional details about the world of .NET.

The concepts presented here will be discussed in more detail as we progress through the book. So if you missed it the first time, you will have a second chance to figure it out.

RECAP

33

C H A P T E R

2

 

 

Getting started with

Visual Studio .NET

2.1Programming with Visual Studio .NET 35

2.2Adding controls 43

2.3Loading files 54

2.4Resizing forms 61

2.5Recap 65

This chapter will take a look at Microsoft’s newest interactive development environment, or IDE. This, of course, is Visual Studio .NET, sometimes referred to as Visual Studio 7.0 or VS .NET.1 Visual Studio .NET provides a number of advances over previous versions of Microsoft’s development environments that make it worth a look. The environment does use a lot of resources, which may make it inappropriate for some older machines with less memory or for savvy developers that prefer a good text editor and a set of build files.

Either method of development is possible with this book. Since Visual Studio is intended as the development environment of choice for .NET, the rest of this book will use Visual Studio in its examples. If you are comfortable using command-line programs and/or makefiles, you should be able to follow these examples and associated code excerpts to write the code in your favorite editor.

1Early versions of this environment, including the Beta2 version, were called Visual Studio.NET, with no space. This was later changed, but you will likely see both versions of the name. The official name includes the extra space.

34

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