C#.NET Illuminated Art Gittleman Copyright 2003 Table of Contents Preface 1. Introduction 1.1 Event-Driven Programming Windows Applications Using a Database Web Applications Web Services Mobile Applications Crystal Reports 1.2 Computing with C# Hardware Software High-Level Languages History C# Features 1.3 Visual Studio .NET 2. Creating an Application 2.1 Creating a Windows Application The Start Page Creating a Project The Properties Window Changing Properties 2.2 Adding Controls The Toolbox TextBox Label Code for an Event IntelliSense Running an Application Closing the Project 2.3 Positioning and Sizing Controls Anchoring Aligning Text Docking Moving and Sizing Controls 2.4 Using a Button Setting Properties Handling the Click Event Context Sensitive Help 3. Controls for Windows Forms 3.1 Using Radio Buttons and Link Labels Radio Buttons Adding a Link Grouping Radio Buttons Adding Another Group 3.2 More Boxes PictureBox CheckBox ListBox ComboBox 3.3 Keeping Track DateTimePicker NumericUpDown Enabling the Display Timer StatusBar 3.4 Menus and Dialogs MainMenu RichTextBox File Dialogs A Print Dialog A Color Dialog A Font Dialog 4. Variables and Types 4.1 Variables and Assignment Identifiers Keywords The Character Set Variables Assignment Illustrating Variables Constants 4.2 Types Formatting Format Specifiers Field Width 4.3 Operators and Expressions Precedence of Arithmetic Operators Combining Assignment and Arithmetic Increment and Decrement Operators Relational Operators and Expressions The AND, OR, and NOT Operators Conditional AND Conditional OR Logical Complement Operator Precedence Combining AND with OR 5. Selection and Repetition 5.1 The if and if-else Statements The if Statement The if-else Statement Blocks 5.2 Nested Ifs and the Switch Statement Nested If Statements Pairing Else with If The Switch Statement 5.3 Repetition The while Statement Loop Termination The for Statement The Do Statement 6. Reference Types 6.1 Arrays Multiple ListBox Selections Using the Documentation A CheckBox Array A Search Game Random Numbers Array Variables and Values 6.2 Strings Visualizing a String Creating a String A String Property A String Indexer String Methods Overloaded Methods Class Methods Using StringBuilder 6.3 Library Classes Namespaces Control Objects 7. Using a Database 7.1 The Northwind Database Relational Databases Queries 7.2 The Connected Model Connecting to a Database Building a Command Reading and Displaying the Data 7.3 The Disconnected Model The Data Adapter Configuration Wizard A Query Builder A Data Set Using the Data Form Wizard 7.4 Using Multiple Tables Building the Query Displaying the Query Results 8. Web Applications 8.1 HTML Some HTML tags 8.2 Web Server Controls and Code Behind Hosting a Web Page Server Controls Code Behind More Web Controls 8.3 Accessing a Database Adding a Connection Configuring a Command Displaying in a DataGrid Writing the Event Handler Choosing Data to Display 8.4 Using Multiple Web Forms Redirecting a Response The AutoPostBack Property Adding a Web Form to a Project Initializing the Page Hidden State 9. Validation Controls 9.1 Checking Required Fields 9.2 Range Checking String Values Integer Values Dates Currency 9.3 Comparing Values Client-Side vs. Server-Side Validation 9.4 Validating Expressions and Summarizing Validating Expressions Summarizing Validation Errors 10. XML 10.1 XML and Information The Limitations of HTML XML Syntax 10.2 Schemas Building a Schema in Visual Studio .NET Valid Documents Using a Schema to Create an XML Document 10.3 From Data to XML Northwind Data to XML The Document Object Mode (DOM) Processing an XML Document 10.4 Transforming XML XSLT Stylesheets Using a Stylesheet 11. Web Services 11.1 Web Service Clients Adding a Web Reference Asynchronous Calls The Event Handler and the Callback Methods 11.2 Creating a Web Service Testing the Web Service A Client for the Reverse Service 11.3 Accessing Data Creating a Web Service Creating the Client 12. Mobile Applications 12.1 Introduction Mobile Devices Operating Systems The .NET Compact Framework Mobile Web Application 12.2 A Simple Mobile Web Application Creating a Web Application The Windows CE .NET Emulator The Pocket PC 2002 Emulator 12.3 A Smart Device Application Using Tabs Saving the Appointment List Initializing the Appointment List 12.4 Accessing Web Services Adding Web References 13. Crystal Reports 13.1 Creating a Simple Report Adding and Creating a Report Viewing the Report Filtering 13.2 Adding Features to a Report The Data Tab The Fields Tab The Group Tab The Total Tab The Remaining Tabs Viewing the Report 13.3 Reports via the Web Viewing a Report in a Web Form A Web Service Report Accessing the Web Service Appendix A C# Keywords Appendix B Operator Precedence Table Appendix C The ASCII Character Set Answers to Odd-Numbered Test Your Understanding Exercises Index