文件名称:Hungry Minds - Visual Basic.NET Visual Blueprint (VBL).pdf
文件大小:14.1MB
文件格式:PDF
更新时间:2022-09-04 02:57:28
Hungry Minds Visual Basic NET
1)GETTING STARTED WITH VISUAL BASIC .NET An Introduction to Visual Basic .NET ................................................................................2 Install Visual Studio .NET....................................................................................................4 Using the Development Studio ..........................................................................................6 Object-Oriented Concepts ................................................................................................8 Understanding the Framework ........................................................................................10 Language Basics ..................................................................................................................12 Language Changes from Visual Basic 6 ............................................................................14 Using the Upgrade Wizard ................................................................................................16 Create a Project ..................................................................................................................18 Work with Project Files ....................................................................................................20 Build and Run a Project ....................................................................................................22 2)GETTING STARTED WITH WINDOWS FORMS Create a Windows Application ........................................................................................24 An Introduction to Windows Forms ................................................................................26 Add a Control to a Form ..................................................................................................28 Set a Property ....................................................................................................................30 Write Event Code ..............................................................................................................32 Resize Controls ..................................................................................................................34 Add a Menu ........................................................................................................................36 Create a Context-Sensitive Menu ....................................................................................38 Add a New Form ................................................................................................................40 Create a Dialog Box ..........................................................................................................42 Using Message Boxes ........................................................................................................44 Add an Owned Form ........................................................................................................46 Order Tab Key Movement ................................................................................................48 TABLE OF CONTENTS 013649-4 FM.F 12/3/01 9:08 AM Page viii 3)WORK WITH CONTROLS Using Buttons ....................................................................................................................50 Using Label Controls ........................................................................................................51 Work with Imagelists ........................................................................................................52 Allow Text Entry ................................................................................................................54 Using the Rich Text Control ..............................................................................................56 Provide Option Controls ..................................................................................................58 Frame Controls ..................................................................................................................60 Work with Panels ..............................................................................................................61 List Items ............................................................................................................................62 Select Numeric Data ........................................................................................................64 Create Timed Events ..........................................................................................................66 Provide Date Selection ......................................................................................................68 Explore List Views ..............................................................................................................70 Explore Tree Views ............................................................................................................72 Create a Toolbar ................................................................................................................74 Provide Status Information ..............................................................................................76 Create a Tab Interface ......................................................................................................78 Provide Error Messages ....................................................................................................80 4)PROGRAMMING IN VISUAL BASIC .NET Create a Console Application ..........................................................................................82 Add a Method ....................................................................................................................84 Declare a Variable ..............................................................................................................86 Using Variable Data Types ................................................................................................88 Work with Operators ........................................................................................................90 Create a String ....................................................................................................................92 Work with Strings ..............................................................................................................94 Pass Information through a Method ................................................................................96 Using the If Statement ......................................................................................................98 Using the Select Case Statement ..................................................................................100 Using For Loops ................................................................................................................102 Using Do Loops ................................................................................................................104 Create an Array ................................................................................................................106 Work with Arrays ............................................................................................................108 ix VISUAL BASIC .NET: Your visual blueprint for building versatileprograms on the .NET Framework 013649-4 FM.F 12/3/01 9:08 AM Page ix x 5)PROVIDE INPUT AND OUTPUT Using a File Stream ..........................................................................................................110 Read from a Stream ........................................................................................................112 Write to a Stream ............................................................................................................113 Watch for File System Changes ......................................................................................114 Access File Information ..................................................................................................116 Access Directory Information ........................................................................................118 Provide a File Dialog Box ................................................................................................120 Using the PrintDocument Control ................................................................................122 Using the Printer Dialog Box ..........................................................................................124 Using the Page Setup Dialog Box ..................................................................................126 Create a Print Preview ....................................................................................................128 Download from a Web Server ........................................................................................130 Make a Connection to a Server ....................................................................................132 Accept Incoming Connections ......................................................................................134 6)CREATE GRAPHICS AND MULTIMEDIA Add a Picture to a Form ..................................................................................................136 Using the Color Dialog Box ............................................................................................138 Understandingthe Graphics Object ..............................................................................140 Create a Brush ..................................................................................................................142 Create a Pen ....................................................................................................................144 Draw Bitmaps and Images ..............................................................................................146 Draw Simple Primitives ..................................................................................................148 Draw a Curve ..................................................................................................................150 Draw Text ..........................................................................................................................152 Create a Path ....................................................................................................................154 Using Regions ..................................................................................................................156 Create a Shaped Window ..............................................................................................158 7)WORK WITH CLASSES Create a Class ..................................................................................................................160 Define a Member Variable ..............................................................................................162 Define a Property ............................................................................................................164 Create a Constructor or Destructor ..............................................................................166 TABLE OF CONTENTS 013649-4 FM.F 12/3/01 9:08 AM Page x Create an Event ................................................................................................................168 Using An Existing Class ....................................................................................................170 Define an Interface ..........................................................................................................172 Implement an Interface ..................................................................................................174 Using Structures ..............................................................................................................176 Using Collections ............................................................................................................178 8)USING ADVANCED OOP TECHNIQUES Overload a Method ........................................................................................................180 Inherit from an Existing Class ........................................................................................182 Create a Shared Method ................................................................................................184 Create a Shared Variable ................................................................................................186 Using Delegate and AddressOf ......................................................................................188 Using Namespaces ..........................................................................................................190 Create a Namespace ........................................................................................................192 Inherit a Form ..................................................................................................................194 Create a Thread ................................................................................................................196 Write Thread-Safe Code ................................................................................................198 Modify Thread Execution ................................................................................................200 9)ACCESS ADO.NET An Introduction to Databases ........................................................................................202 An Introduction to ADO.NET ........................................................................................204 Create a Database Connection ......................................................................................206 Add a Connection to a Form ..........................................................................................208 Work with Data Tables ..................................................................................................210 Work with Data Columns ..............................................................................................212 Work with Data Rows ....................................................................................................214 Add a DataView Component ........................................................................................216 Bind a Control on a Form ..............................................................................................218 Move through a Dataset ..................................................................................................220 Edit Data Using Bound Controls ....................................................................................222 Validate Data ....................................................................................................................224 Create a Data Relationship ............................................................................................226 Add a Data Grid Control ................................................................................................228 xi VISUAL BASIC .NET: Your visual blueprint for building versatileprograms on the .NET Framework 013649-4 FM.F 12/3/01 9:08 AM Page xi xii 10)USING WEB FORMS An Introduction to Web Forms ......................................................................................230 Create a Web Application ..............................................................................................232 Using a Web Form ..........................................................................................................234 Add a Label Control ........................................................................................................236 Add a Hyperlink Control ................................................................................................237 Add a Button Control ......................................................................................................238 Add Option Controls ......................................................................................................240 Work with Option List Controls ....................................................................................242 Using Validation Controls ..............................................................................................244 Work with Regular Expression Validation ....................................................................246 Provide a Validation Summary ......................................................................................248 Add an Additional Web Form ........................................................................................250 Bind a Field to a List Control ..........................................................................................252 Add a DataGrid Control ..................................................................................................254 Change the Appearance of a DataGrid ........................................................................256 Edit Data in a DataGrid ..................................................................................................258 11)USING WEB SERVICES Create a Windows Service ..............................................................................................260 Using the Event Log ........................................................................................................262 Install a Windows Service ..............................................................................................264 Monitoring a Windows Service ......................................................................................266 Create a Web Service ......................................................................................................268 Add a Web Service Method ............................................................................................270 Using the Service Help Interface ..................................................................................272 Using Web Services ........................................................................................................274 12)DEVELOPING COMPONENTS An Introduction to Component Creation ....................................................................276 Create a Component ......................................................................................................278 Create a Windows Forms Control ................................................................................280 Handle Default Properties ..............................................................................................282 TABLE OF CONTENTS 013649-4 FM.F 12/3/01 9:08 AM Page xii Add a Member ................................................................................................................284 Add an Event ....................................................................................................................286 Using Standard Controls ................................................................................................288 Create a Control from Scratch ......................................................................................290 Reference a Library ..........................................................................................................292 Create a Web User Control ............................................................................................294 Add a Web Control to a Page ........................................................................................296 Using Web Control Libraries ..........................................................................................298 13)PACKAGE YOUR APPLICATION Debug an Application ......................................................................................................300 Monitor Program Execution ............................................................................................302 Recover from an Error ....................................................................................................304 Using the Registry ............................................................................................................306 Provide Access to Disabled Users ..................................................................................308 Create a Windows Installer ............................................................................................310 Customize your Installation ............................................................................................312 APPENDIX What’s on the CD-ROM ..................................................................................................314 Using the E-Version of this Book ....................................................................................316 Hungry Minds,Inc.End-User License Agreement........................................................318 INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .320