1. Trang chủ
  2. » Công Nghệ Thông Tin

Netframwork 2.0 (phần 1) pdf

50 313 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 50
Dung lượng 681,69 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

❑ Use the integrated development environment IDE to add a control to a Windows Form or other container control of a project at design time.. 3 Lesson 1: Adding and Configuring Windows F

Trang 2

1 2 3 4 5 6 7 8 9 QWT 0 9 8 7 6 5

Distributed in Canada by H.B Fenn and Company Ltd

A CIP catalogue record for this book is available from the British Library

Microsoft Press books are available through booksellers and distributors worldwide For further information about international editions, contact your local Microsoft Corporation office or contact Microsoft Press Inter­ national directly at fax (425) 936-7329 Visit our Web site at www.microsoft.com/mspress Send comments

to tkinput@microsoft.com

Microsoft, Microsoft Press, ActiveX, Excel, IntelliSense, Internet Explorer, MSN, Tahoma, Visual Basic,

Trang 5

1

Introduction xxiii

Hardware Requirements xxiii

Software Requirements xxiv

Using the CD and DVD xxiv

How to Install the Practice Tests xxv

How to Use the Practice Tests xxv

How to Uninstall the Practice Tests xxvi

Microsoft Certified Professional Program xxvii

Technical Support xxvii

Evaluation Edition Software Support xxviii

What do you think of this book?

We want to hear from you!

Microsoft is interested in hearing your feedback about this publication so we can continually improve our books and learning resources for you To participate in a brief

online survey, please visit: www.microsoft.com/learning/booksurvey/

vii

Trang 7

Contents ix

3

Trang 8

Lesson 3: Configuring the WebBrowser Control and the NotifyIcon

Trang 9

xi

Contents

Trang 11

Contents xiii

6

Trang 13

Contents xv

Trang 15

Contents xvii

9

Trang 16

10

Trang 17

Contents xix

11

Trang 19

Contents xxi

14

Trang 21

This training kit is designed for developers who plan to take Microsoft Certified Tech­nical Specialist (MCTS) exam 70-526, as well as for developers who need to know how to develop Microsoft Windows–based applications using the Microsoft NET Framework 2.0 We assume that before you begin using this kit you have a working knowledge of Windows and Microsoft Visual Basic or C#

By using this training kit, you’ll learn how to do the following:

■ Create a user interface (UI) for a Windows Forms application by using standard controls

■ Integrate data in a Windows Forms application

■ Implement printing and reporting functionality in a Windows Forms application

■ Enhance usability

■ Implement asynchronous programming techniques to improve the user experience

■ Develop Windows Forms controls

■ Configure and deploy applications

Hardware Requirements

The following hardware is required to complete the practice exercises:

■ Computer with a 600 MHz or faster processor

■ 192 MB of RAM or more

■ 2 GB of available hard disk space

■ DVD-ROM drive

■ 1,024 x 768 or higher resolution display with 256 colors

■ Keyboard and Microsoft mouse or compatible pointing device

xxiii

Trang 22

❑ Windows Server 2003, x64 Editions (WOW)

❑ Windows Server 2003 R2

❑ Windows Server 2003 R2, x64 Editions (WOW)

❑ Microsoft Windows Vista

■ Microsoft Visual Studio 2005 (A 90-day evaluation edition of Visual Studio 2005 Professional Edition is included on DVD with this book.)

Using the CD and DVD

A companion CD and an evaluation software DVD are included with this training kit The companion CD contains the following:

Practice tests You can reinforce your understanding of how to create NET Framework 2.0 applications by using electronic practice tests you customize to meet your needs from the pool of Lesson Review questions in this book Or you

Trang 23

Introduction xxv

The evaluation software DVD contains a 90-day evaluation edition of Visual Studio

2005 Professional Edition, in case you want to use it with this book

How to Install the Practice Tests

To install the practice test software from the companion CD to your hard disk, do the following:

1 Insert the companion CD into your CD drive, and accept the license agreement

A CD menu appears

NOTE If the CD menu doesn’t appear

If the CD menu or the license agreement doesn’t appear, AutoRun might be disabled on your computer Refer to the Readme.txt file on the CD-ROM for alternate installation instructions

2 Click the Practice Tests item, and follow the instructions on the screen

How to Use the Practice Tests

To start the practice test software, follow these steps:

1 Click Start/All Programs/Microsoft Press Training Kit Exam Prep A window

appears that shows all the Microsoft Press training kit exam prep suites installed

on your computer

2 Double-click the lesson review or practice test you want to use

NOTE Lesson REviews vs Practice tests

Select the (70-526) Microsoft NET Framework 2.0–Windows-Based Client Development

Foundation lesson review to use the questions from the “Lesson Review” sections of this book Select the (70-526) Microsoft NET Framework 2.0–Windows-Based Client Development prac­

tice test to use a pool of 300 questions similar to those in the 70-526 certification exam

Lesson Review Options

When you start a lesson review, the Custom Mode dialog box appears so that you can configure your test You can click OK to accept the defaults, or you can customize the number of questions you want, how the practice test software works, which exam objectives you want the questions to relate to, and whether you want your lesson review to be timed If you’re retaking a test, you can select whether you want to see all the questions again or only those questions you missed or didn’t answer

Trang 24

Practice Test Options

When you start a practice test, you choose whether to take the test in Certification Mode, Study Mode, or Custom Mode

Certification Mode Closely resembles the experience of taking a certification exam The test has a set number of questions, it’s timed, and you can’t pause and restart the timer

Study Mode Creates an untimed test in which you can review the correct answers and the explanations after you answer each question

Custom Mode Gives you full control over the test options so that you can cus­tomize them as you like

In all modes, the user interface you see when taking the test is basically the same but

Trang 25

Introduction xxvii

Microsoft Certified Professional Program

The Microsoft certifications provide the best method to prove your command of cur­rent Microsoft products and technologies The exams and corresponding certifica­tions are developed to validate your mastery of critical competencies as you design and develop, or implement and support, solutions with Microsoft products and tech­nologies Computer professionals who become Microsoft-certified are recognized as experts and are sought after industry-wide Certification brings a variety of benefits to the individual and to employers and organizations

MORE INFO All the Microsoft Certifications

For a full list of Microsoft certifications, go to www.microsoft.com/learning/mcp/default.asp

Technical Support

Every effort has been made to ensure the accuracy of this book and the contents of the companion CD If you have comments, questions, or ideas regarding this book or the companion CD, please send them to Microsoft Press by using either of the following methods:

Trang 27

shapes and customize them to the user’s needs Forms are hosts for controls, which provide the main functionality of the user interface Special controls called container controls can be used to control the layout of the user interface

Exam objectives in this chapter:

■ Add and configure a Windows Form

❑ Add a Windows Form to a project at design time

❑ Configure a Windows Form to control accessibility, appearance, behavior, configuration, data, design, focus, layout, style, and other functionality

■ Manage control layout on a Windows Form

Group and arrange controls by using the Panel control, GroupBox control, TabControl control, FlowLayoutPanel control, and TableLayoutPanel control

Use the SplitContainer control to create dynamic container areas

Add and configure a Windows Forms control

❑ Use the integrated development environment (IDE) to add a control to a Windows Form or other container control of a project at design time

❑ Add controls to a Windows Form at run time

Lessons in this chapter:

■ Lesson 1: Adding and Configuring Windows Forms 3

■ Lesson 2: Managing Control Layout with Container Controls 24

1

Trang 28

Real World

Matt Stoecker

When I develop a Windows Forms application, I pay special attention to the design of the user interface A well-thought-out user interface that flows logically

Trang 29

3

Lesson 1: Adding and Configuring Windows Forms

Lesson 1: Adding and Configuring Windows Forms

This lesson describes how to create and configure Windows Forms You will learn how to create forms and refer to them in code, alter the visual properties of the form, and control the behavior of the form at run time

After this lesson, you will be able to:

■ Add a Windows Form to a project at design time

■ Add a new Windows Form at run time

■ Resize a window at design time or run time

■ Identify and set the properties that determine a form’s appearance and behavior at run time

■ Refer to the default instance of a form in code

■ Create a non-rectangular form

Estimated lesson time: 45 minutes

Overview of Windows Forms

Windows Forms are the basic building block of the user interface They provide a container that hosts controls and menus and allow you to present an application in

a familiar and consistent fashion Forms can receive user input in the form of key­strokes or mouse interactions and can display data to the user through hosted con­trols Although it is possible to create applications that do not contain forms, such

as console applications or services, most applications that require sustained user interaction will include at least one Windows Form, and complex applications fre­quently require several forms to allow the program to execute in a consistent and logical fashion

When you create a new Windows Forms project, a form named Form1 is added to your project by default You can edit your form by adding controls and other visual elements in the designer, which is a graphic representation of a designable, visual ele­

ment (such as a Form) that appears in the Visual Studio Integrated Development Envi­

ronment (IDE) The Visual Studio IDE is shown in Figure 1-1

Trang 30

Figure 1-1 A Windows Form in the Visual Studio IDE

Adding Forms to Your Project

Most projects will require more than one form You can add and configure additional forms at design time, or you can create instances of pre-designed forms in code at run time

Trang 31

5

Lesson 1: Adding and Configuring Windows Forms

To access the default instance of a form at run time (Visual Basic only)

1 Refer to the form by its name You can call methods or access properties from

this default instance For example:

' VB

2 If referring to a form from within that form’s code, you cannot use the default

instance You must use the special keyword Me (Visual Basic) or this (C#) to

access the form’s properties and methods

To access a form’s methods and properties from inside its code

1 Use the keyword Me (Visual Basic) or this( C#) For example:

' VB

Me.Text = "J and J's Wine Shop – Main Page"

// C#

this.Text = "J and J's Wine Shop – Main Page";

2 You can also create new instances of forms at run time by declaring a variable

that represents a type of form and creating an instance of that form

To add a form to your application at run time

1 Declare and instantiate a variable that represents your form This example assumes

that you have already designed a form named Form1 in your project:

' VB

// C#

Properties of Windows Forms

The visual appearance of your user interface is an important part of your application

A user interface that is poorly designed is difficult to learn and will, therefore, increase training time and expense You can modify the appearance of your user interface by using Windows Forms properties

Trang 32

Figure 1-2 The Properties window

Table 1-1 summarizes some of the Windows Forms properties that are important in the look and feel of the application Note that this is not an exhaustive list of all Windows Forms properties but, rather, a selected subset

Table 1-1 Some Properties of the Form Class

Trang 33

7

Lesson 1: Adding and Configuring Windows Forms

Table 1-1 Some Properties of the Form Class

Property Description

moved over the form

input If Enabled is set to False, all controls contained by

the form are likewise disabled

by the form will also adopt this font unless their Font

property is set separately

used to display text All controls contained by the form will also adopt this forecolor unless their forecolor prop­erty is set separately

der and title bar

property indicates the starting location of the form rela­tive to the upper left-hand corner of the screen

erty is set to a size of (0,0) the form has no upper size

limit

resize the form

Trang 34

displayed

other forms that do not have this property set to True

or set to the size indicated by the Size property when

first shown

Modifying the Look and Feel of the Form

You can use the Property Grid to set properties of the form at design time Properties set in this manner will retain their values until the application starts, at which time

Trang 35

9

Lesson 1: Adding and Configuring Windows Forms

fies any subvalues of the property and assign it to the property as shown in the fol­lowing pseudocode example:

' VB

PropertyY = New Class(value,value)

// C#

PropertyY = new Class(value,value);

The (Name) property, which represents the name of the Form class, is an exception

This property is used within the namespace to uniquely identify the class that the

Form is an instance of and, in the case of Visual Basic, is used to access the default

instance of the form

Setting the Title of the Form

The name of the form is the name that is used to refer to the Form class or the default

instance of a form (Visual Basic only) in code, but it is also useful for the form to have

a title that is visible to users This title might be the same as the name of the form but

is more often a description of the form itself, such as Data Entry The title can also be used to convey information to the user, such as “Processing Entries — My Application”

or “Customer Entry — My Application” The title appears in the title bar and on the taskbar

You can change the title of a form by changing the Text property To change the title of

a form at design time, set the Text property of the form in the Property Grid To change the title of a form at run time, set the Text property of the form in code, as shown in

the following code:

' VB

Form1.Text = "Please enter your address"

// C#

Form1.Text = "Please enter your address";

Setting the Border Style of the Form

The border style of a form determines how the border of the form looks and, to a certain

extent, how a form behaves at run time Depending on the setting, the FormBorderStyle

property can control how the border appears, whether a form is resizable by the user at run time, and whether various control boxes appear (although these are also deter­

mined by other form properties) The FormBorderStyle property has seven possible val­

ues, which are explained in Table 1-2

Ngày đăng: 07/07/2014, 05:20

TỪ KHÓA LIÊN QUAN