00 0789728230 FM 11/21/02 1:22 PM Page i CERTIFICATION MCAD/MCSD.NET Developing and Implementing Windows- Based Applications with Microsoft Visual C# .NET and Microsoft Visual Studio .NET Exam 70-316 Amit Kalani Training Guide 00 0789728230 FM 11/21/02 1:22 PM Page ii MCAD/MCSD.NET TRAINING GUIDE: EXECUTIVE EDITOR Jeff Riley D I W - EVELOPING AND MPLEMENTING INDOWS DEVELOPMENT EDITOR B A M ASED PPLICATIONS WITH ICROSOFT Steve Rowe V C# .NET M V ISUAL AND ICROSOFT ISUAL MANAGING EDITOR S .NET, E (70-316) Thomas F. Hayes TUDIO XAM PROJECT EDITOR Copyright 2003 by Que Publishing Natalie Harris Tonya Simpson All rights reserved. No part of this book shall be reproduced, stored in COPY EDITOR a retrieval system, or transmitted by any means, electronic, mechanical, Kitty Wilson Jarrett photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the INDEXER use of the information contained herein. Although every precaution Ginny Bess has been taken in the preparation of this book, the publisher and PROOFREADER author assume no responsibility for errors or omissions. Nor is any lia- Juli Cook bility assumed for damages resulting from the use of the information TECHNICAL EDITORS contained herein. Kourosh Ardestani International Standard Book Number: 0-7897-2823-0 Steve Heckler Library of Congress Catalog Card Number: 2002108892 TEAM COORDINATORS Rosemary Lewis Printed in the United States of America Kimberley Herbert First Printing: December 2002 INTERIOR DESIGNER Louisa Klucznik 05 04 03 02 4 3 2 1 COVER DESIGNER Charis Ann Santillie Trademarks All terms mentioned in this book that are known to be trademarks or PAGE LAYOUT service marks have been appropriately capitalized. Que cannot attest to Cheryl Lynch the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Microsoft is a registered trademark of Microsoft Corporation. Windows is a registered trademark of Microsoft Corporation. Visual C# is a registered trademark of Microsoft Corporation. Visual Studio is a registered trademark of Microsoft Corporation. Warning and Disclaimer Every effort has been made to make this book as complete and as accu- rate as possible, but no warranty or fitness is implied. The information provided is on an “as is” basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book or from the use of the CD or programs accompanying it. 00 0789728230 FM 11/21/02 1:22 PM Page iii Que Certification • 201 West 103rd Street • Indianapolis, Indiana 46290 A Note from Series Editor Ed Tittel Congratulations on your purchase of the 70-316 Training Guide, the finest exam preparation book in the marketplace! As Series Editor of the highly regarded Training Guide series, I can assure you that you won’t be disappointed. You’ve taken your first step toward passing the 70-316 exam, and we value this opportunity to help you on your way! As a “Favorite Study Guide Author” finalist in a 2002 poll of CertCities readers, I know the importance of delivering good books. You’ll be impressed with Que Certification’s stringent review process, which ensures the books are high-quality, relevant, and technically accurate. Rest assured that at least a dozen industry experts—including the panel of certification experts at CramSession—have reviewed this material, helping us deliver an excellent solution to your exam preparation needs. We’ve also added a preview edition of PrepLogic’s powerful, full-featured test engine, which is trusted by certification students throughout the world. As a 20-year-plus veteran of the computing industry and the original creator and editor of the Exam Cram series, I’ve brought my IT experience to bear on these books. During my tenure at Novell from 1989 to 1994, I worked with and around its excellent education and certification department. At Novell, I witnessed the growth and development of the first really big, successful IT certification program—one that was to shape the industry forever afterward. This experience helped push my writing and teaching activities heavily in the cer- tification direction. Since then, I've worked on more than 70 certification related books, and I write about certification topics for numerous Web sites and for Certificationmagazine. In 1997 when Exam Cram was introduced, it quickly became the best-selling computer book series since “...For Dummies,” and the best-selling certification book series ever. By maintaining an intense focus on the subject matter, tracking errata and updates quickly, and following the certification market closely, Exam Cram was able to establish the domi- nant position in cert prep books. You will not be disappointed in your decision to purchase this book. If you are, please contact me at [email protected]. All suggestions, ideas, input, or constructive criticism are welcome! 00 0789728230 FM 11/21/02 1:22 PM Page iv 00 0789728230 FM 11/21/02 1:22 PM Page v Contents at a Glance Introduction ..............................................................................................................................................1 Study and Exam Prep Tips....................................................................................................................9 PART I Developing Windows Applications 1 Introducing Windows Forms..........................................................................................................21 2 Controls ................................................................................................................................................113 3 Error Handling for the User Interface......................................................................................229 4 Creating and Managing .NET Components and Assemblies........................................283 5 Data Binding ......................................................................................................................................353 6 Consuming and Manipulating Data ........................................................................................427 7 Web Services........................................................................................................................................565 8 Globalization ......................................................................................................................................599 9 Working with Legacy Code..........................................................................................................641 10 User Assistance and Accessibility................................................................................................677 11 Printing..................................................................................................................................................729 PART II Testing, Debugging, and Deploying a Windows Application 12 Testing and Debugging a Windows Application..................................................................775 13 Deploying a Windows Application............................................................................................835 PART III Maintaining and Configuring a Windows Application 14 Maintaining and Supporting a Windows Application......................................................941 15 Configuring a Windows Application........................................................................................991 00 0789728230 FM 11/21/02 1:22 PM Page vi VI MCAD/MCSD TRAINING GUIDE EXAM (70-316) PART IV Final Review Fast Facts............................................................................................................................................1039 Practice Exam ..................................................................................................................................1061 PART V Appendixes A Glossary..............................................................................................................................................1087 B Overview of the Certification Process....................................................................................1091 C What’s on the CD-ROM............................................................................................................1101 D Using the PrepLogic, Preview EditionSoftware ..................................................................1103 E Suggested Readings and Resources..........................................................................................1109 Index....................................................................................................................................................1111 00 0789728230 FM 11/21/02 1:22 PM Page vii CONTENTS VII 00 0789728230 FM 11/21/02 1:22 PM Page viii Table of Contents Introduction 1 How This Book Helps You ..............................................................................................................1 Organization ....................................................................................................................................1 Instructional Features ....................................................................................................................2 Extensive Practice Test Options ................................................................................................2 Final Review ......................................................................................................................................3 What the “Developing and Implementing Windows-Based Applications with Microsoft Visual C# .NET and Microsoft Visual Studio .NET” Exam (Exam 70-316) Covers ........................................................................................................4 Creating User Services ..................................................................................................................4 Creating and Managing Components and .NET Assemblies ......................................5 Consuming and Manipulating Data ......................................................................................5 Testing and Debugging ................................................................................................................5 Deploying a Windows-Based Application ............................................................................5 Maintaining and Supporting a Windows-Based Application ......................................6 Configuring and Securing a Windows-Based Application ............................................6 What You Should Know Before Reading This Book ............................................................6 Hardware and Software You’ll Need ..............................................................................................7 Advice on Taking the Exam ..............................................................................................................8 Study and Exam Prep Tips 9 Study Tips ..............................................................................................................................................10 Study Strategies ............................................................................................................................10 Pretesting Yourself ........................................................................................................................11 Exam Prep Tips ....................................................................................................................................11 The MCP Exam ............................................................................................................................11 Exam Forms ....................................................................................................................................12 New Question Types ..................................................................................................................14 Putting It All Together ..............................................................................................................15 Final Considerations ..........................................................................................................................17 00 0789728230 FM 11/21/02 1:22 PM Page ix PART I: Developing Window Applications 1 Introducing Windows Forms 21 Introduction ..........................................................................................................................................24 Key Concepts ........................................................................................................................................24 An Overview of the .NET Framework ................................................................................25 An Overview of the Development Tools ............................................................................27 Understanding Classes, Inheritance, and Namespaces ..................................................29 Creating a Windows Forms Application ..................................................................................32 Using the System.Windows.Forms.FormClass ....................................................................33 Designing a Windows Form by Using the Windows Forms Designer ..................34 Exploring the Generated Code ..............................................................................................37 Running a Windows Form ......................................................................................................40 Using the ApplicationClass ....................................................................................................42 Using the MessageBoxClass ......................................................................................................46 Setting and Adding Properties to a Windows Form ............................................................48 Using the Visual Designer to Set Windows Form Properties ....................................48 Setting Windows Form Properties Programmatically ..................................................51 Adding New Properties to a Windows Form ....................................................................57 Using Visual Inheritance ..................................................................................................................61 Event Handling ..................................................................................................................................64 Handling Events by Attaching a Delegate ........................................................................65 Handling Events by Overriding a Protected Method of a Base Class ....................71 Building Graphical Interface Elements by Using the System.Drawing Namespace ..........................................................................................................................................76 Understanding the GraphicsObjects ..................................................................................77 Understanding the Windows Forms Coordinate System ............................................78 Drawing Text on a Form ..........................................................................................................79 Drawing Shapes ............................................................................................................................85 Working with Images ..................................................................................................................94 Exercises ........................................................................................................................................102 Review Questions ......................................................................................................................105 Exam Questions ........................................................................................................................105 Answers to Review Questions ..............................................................................................108 Answers to Exam Questions ..................................................................................................109 00 0789728230 FM 11/21/02 1:22 PM Page x X MCAD/MCSD TRAINING GUIDE EXAM (70-316) 2 Controls 113 Introduction ......................................................................................................................................116 Adding Controls to a Windows Form ....................................................................................116 Adding Controls by Using the Windows Forms Designer ......................................117 Adding Controls Programmatically ....................................................................................118 Setting Properties of Controls ....................................................................................................120 Important Common Properties of Controls ..................................................................121 Configuring the Order of Tabs ............................................................................................125 Handling Control Events ..............................................................................................................126 Dialog Boxes ......................................................................................................................................135 Common Dialog Boxes ..........................................................................................................135 Creating a Custom Dialog Box ............................................................................................139 Common Windows Forms Controls ......................................................................................142 The Labeland LinkLabelControls ....................................................................................143 The TextBoxand RichTextBoxControls ..........................................................................146 The PictureBoxControl ........................................................................................................148 The GroupBoxand PanelControls ......................................................................................149 The Button, CheckBox, and RadioButtonControls ......................................................151 The ListBox, CheckedListBox, and ComboBoxControls ..............................................155 The DomainUpDownand NumericUpDownControls ..........................................................165 The MonthCalendarand DateTimePickerControls ......................................................168 The TreeViewand ListViewControls ................................................................................172 The Timer, TrackBar, and ProgressBarControls ........................................................177 The HScrollBarand VScrollBarControls ......................................................................180 The TabControlControl ........................................................................................................183 Creating Menus and Menu Items ............................................................................................187 The MainMenuControl ..............................................................................................................189 The ContextMenuControl ......................................................................................................197 The StatusBarControl ..........................................................................................................203 The ToolBarControl ................................................................................................................207 Creating MDI Applications ........................................................................................................210 Exercises ........................................................................................................................................218 Review Questions ......................................................................................................................220 Exam Questions ........................................................................................................................220 Answers to Review Questions ..............................................................................................224 Answers to Exam Questions ..................................................................................................225
Description: