1. Trang chủ
  2. » Khoa Học Tự Nhiên

Teach yourself microsoft VisualCSharp

564 45 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

Nội dung

This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] • • Table of Contents Index Sams Teach Yourself Microsoft® Visual C#™ NET in 24 Hours By James Foxall Publisher: Sams Publishing Pub Date: August 20, 2003 ISBN: 0-672-32538-1 Pages: 600 In just 24 lessons of one hour or less, you will be creating your own Windows applications using the power and functionality of Visual C# NET Using a straightforward, step-by-step approach, each lesson builds on the previous ones, enabling you to learn the essentials of Visual C# NET from the ground up Step-by-step instructions walk you through the most common Visual C# NET tasks while questions and answers, quizzes, and exercises at the end of each hour help you test your knowledge Notes and tips point out shortcuts and solutions and help steer you clear of potential problems You will learn The basics of Visual C# and then quickly begin applying your knowledge to real-world Windows programming tasks Important features such as building forms, working with controls, looping, debugging, and working with data in the world of NET Tips that ease migration from Visual C++ and Visual Basic to Visual c# NET 2003 [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] • • Table of Contents Index Sams Teach Yourself Microsoft® Visual C#™ NET in 24 Hours By James Foxall Publisher: Sams Publishing Pub Date: August 20, 2003 ISBN: 0-672-32538-1 Pages: 600 Copyright About the Author Acknowledgments We Want to Hear from You! Introduction Who Should Read This Book How This Book Is Organized Conventions Used in This Book Onward and Upward! Part I The Visual Studio NET Environment Hour Jumping in with Both Feet: A Visual C# NET Programming Tour Getting Started with Visual C# NET Creating a New Project Understanding the Visual Studio Environment Changing the Characteristics of Objects Naming Objects Setting the Text Property of the Form Giving the Form an Icon Changing the Size of the Form Adding Controls to a Form Designing an Interface Adding an Invisible Control to a Form Writing the Code Behind an Interface Running a Project Summary Q&A Workshop Hour Navigating Visual Studio NET This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Hour Navigating Visual Studio NET Using the Visual Studio NET Start Page Navigating and Customizing the Visual Studio NET Environment Adding Controls to a Form Using the Toolbox Setting Object Properties Using the Properties Window Managing Projects Managing Project Files with the Solution Explorer Getting Help Summary Q&A Workshop Hour Understanding Objects and Collections Understanding Objects Understanding Properties Understanding Methods Building a Simple Object Example Project Understanding Collections Using the Object Browser Summary Q&A Workshop Hour Understanding Events Understanding Event-Driven Programming Building an Event Example Project Summary Q&A Workshop Part II Building a User Interface Hour Building Forms: The Basics Changing the Name of a Form Changing the Appearance of a Form Showing and Hiding Forms Summary Q&A Workshop Hour Building Forms: Advanced Techniques Working with Controls Creating Topmost Windows Creating Transparent Forms Creating Scrollable Forms Creating MDI Forms Setting the Startup Object Summary Q&A Workshop Hour Working with the Traditional Controls Displaying Static Text with the Label Control Allowing Users to Enter Text Using a Text Box Creating Buttons Creating Containers and Groups of Option Buttons Displaying a List with the List Box Creating Drop-Down Lists Using the Combo Box Summary This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Q&A Workshop Hour Using Advanced Controls Creating Timers Creating Tabbed Dialog Boxes Storing Pictures in an Image List Building Enhanced Lists Using the List View Creating Hierarchical Lists with the Tree View Summary Q&A Workshop Hour Adding Menus and Toolbars to Forms Building Menus Programming Menus Using the Toolbar Control Creating a Status Bar Summary Q&A Workshop Hour 10 Creating and Calling Methods Creating Class Members Defining and Writing Methods Creating the User Interface of Your Project Calling Methods Exiting Methods Working with Tasks Summary Q&A Workshop Part III Making Things Happen—Programming Hour 11 Using Constants, Data Types, Variables, and Arrays Understanding Data Types Defining and Using Constants Declaring and Referencing Variables Determining Constant and Variable Scope Naming Conventions Summary Q&A Workshop Hour 12 Performing Arithmetic, String Manipulation, and Date/Time Adjustments Performing Basic Arithmetic Operations with Visual C# NET Comparing Equalities Understanding Boolean Logic Manipulating Strings Working with Dates and Times Summary Q&A Workshop Hour 13 Making Decisions in Visual C# NET Code Making Decisions Using if Statements Evaluating an Expression for Multiple Values Using switch Summary This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Q&A Workshop Hour 14 Looping for Efficiency Looping a Specific Number of Times Using for Statements Using while to Loop an Indeterminate Number of Times Summary Q&A Workshop Hour 15 Debugging Your Code Adding Comments to Your Code Identifying the Two Basic Types of Errors Using Visual C# NET's Debugging Tools Writing an Error Handler Using try catch finally Summary Q&A Workshop Hour 16 Designing Objects Using Classes Understanding Classes Instantiating Objects from Classes Summary Q&A Workshop Hour 17 Interacting with Users Displaying Messages Using the MessageBox.Show() Method Crafting Good Messages Creating Custom Dialog Boxes Interacting with the Keyboard Using the Common Mouse Events Summary Q&A Workshop Hour 18 Working with Graphics Understanding the Graphics Object Working with Pens Using System Colors Working with Rectangles Drawing Common Shapes Printing Text on a Graphics Object Persisting Graphics on a Form Building a Graphics Project Summary Q&A Workshop Part IV Working with Data Hour 19 Performing File Operations Using the Open File Dialog and Save File Dialog Controls Manipulating Files with the File Object Manipulating Directories with the Directory Object Summary Q&A Workshop Hour 20 Controlling Other Applications Using Automation This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Creating a Reference to an Automation Library Creating an Instance of an Automation Server Manipulating the COM Server from the Client Code Summary Q&A Workshop Hour 21 Working with a Database Introduction to ADO.NET Connecting to a Database Manipulating Data Using the Data Form Wizard Summary Q&A Workshop Part V Deploying Solutions and Beyond Hour 22 Deploying a Visual C# NET Solution Creating a Custom Setup Program Running a Custom Setup Program Uninstalling an Application Summary Q&A Workshop Hour 23 Introduction to Web Development Understanding ASP.NET Creating Dynamic Web Content with Web Forms Understanding XML Web Services Summary Q&A Workshop Hour 24 Building a Real-World Application Building the Interface Building the Main Menu Building the Toolbar Adding the List View to Display Albums Adding the Browse For Database OpenFileDialog Control Writing the Code for the CD Cataloger Testing Your Application Part VI Appendices Appendix A The 10,000-Foot View The NET Framework The Common Language Runtime Microsoft Intermediate Language Namespaces and Classes in NET Common Type System Garbage Collection Appendix B Answers to Quizzes Hour Hour Hour Hour Hour Hour This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Hour Hour Hour Hour 10 Hour 11 Hour 12 Hour 13 Hour 14 Hour 15 Hour 16 Hour 17 Hour 18 Hour 19 Hour 20 Hour 21 Hour 22 Hour 23 Index [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] Copyright Copyright © 2004 by Sams Publishing All rights reserved No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher No patent liability is assumed with respect to the use of the information contained herein Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions Nor is any liability assumed for damages resulting from the use of the information contained herein Library of Congress Catalog Card Number: 2003092627 Printed in the United States of America First Printing: August 2003 06 05 04 03 Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized Sams Publishing cannot attest to 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 Warning and Disclaimer Every effort has been made to make this book as complete and as accurate 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 Bulk Sales Sams Publishing offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales For more information, please contact U.S Corporate and Government Sales 1-800-382-3419 corpsales@pearsontechgroup.com For sales outside of the U.S., please contact International Sales 1-317-428-3341 international@pearsontechgroup.com Credits Associate Publisher Michael Stephens Acquisitions Editor Candy Hall Development Editor Mark Renfrow Managing Editor Charlotte Clapp Senior Project Editor This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Senior Project Editor Matthew Purcell Copy Editor Margaret Berson Indexer Chris Barrick Proofreader Leslie Joseph Technical Editor Bill Hatfield Team Coordinator Cindy Teeters Media Developer Dan Scherf Interior Designer Gary Adair Cover Designer Aren Howell Page Layout Point 'n Click Publishing, LLC Dedication James Foxall: To me, cause I wrote the darn thing [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] About the Author James Foxall is vice president of development and support for Tigerpaw Software, Inc (www.tigerpawsoftware.com)— a Microsoft Certified Partner in Omaha, Nebraska, specializing in commercial database applications James manages the Tigerpaw Business Suite, an award-winning CRM product designed to automate contact management, marketing, service and repair, proposal generation, inventory control, and purchasing James's experience in creating certified Office-compatible software has made him an authority on application interface and behavior standards of applications for the Microsoft Windows and Microsoft Office environments James has personally written more than 200,000 lines of commercial production code in both single-programmer and multiple-programmer environments He is the author of numerous books, including Sams Teach Yourself C# in 24 Hours and Practical Standards for Microsoft Visual Basic NET, and he has written articles for Access-Office-VBA Advisor and Visual Basic Programmer's Journal James has a bachelor's degree in management of information systems (MIS), is a Microsoft Certified Solution Developer, and is an international speaker on Microsoft Visual Basic When not programming or writing about programming, he enjoys spending time with his family, playing guitar, doing battle over the chess board, listening to Pink Floyd, playing computer games (Raven Shield multiplayer), and (believe it or not) programming! You can reach James at www.jamesfoxall.com/forums [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] Tab control 2nd 3rd tab order (forms) creating 2nd 3rd Tab Order application 2nd 3rd Tab Order command (View menu) 2nd tabbed dialog boxes creating 2nd 3rd tabbed floating windows 2nd 3rd tables DataTables adding records to 2nd 3rd 4th creating 2nd deleting records from 2nd editing records in navigating 2nd 3rd 4th 5th TabStop property (controls) tags ending (XML) semantic (XML) starting (XML) XML (eXtensible Markup Language) case sensitivity formats Task List displaying taskbar forms removing from tasks creating 2nd deleting Task List displaying Temporary attribute (files) terminating [See exiting] testing CD/Album Catalog application 2nd 3rd events 2nd Excel automation Object Example application 2nd text [See also labels] adding to title bars (forms) 2nd drawing Persisting Graphics application 2nd Font objects 2nd formatting Web Forms 2nd Windows Forms 2nd messages buttons 2nd DialogResult enumeration 2nd displaying 2nd guidelines 2nd This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com icons 2nd 3rd 4th printing on Graphics object 2nd strings characters;counting concatenating 2nd 3rd 4th replacing within 2nd retrieving text from 2nd substrings 2nd 3rd trimming spaces from 2nd text boxes 2nd maximum length of 2nd multiline text boxes 2nd 3rd 4th password fields scrollbars 2nd text alignment 2nd Text Box control Events Example application text boxes 2nd Align Controls application 2nd 3rd Database Example application 2nd Decisions Example application Events Example application Location maximum length of 2nd Method Example application 2nd multiline text boxes 2nd 3rd 4th password fields Persisting Graphics application properties Enabled 2nd MaxLength 2nd Multiline PasswordChar 2nd Scrollbars TextAlign 2nd scrollbars 2nd text alignment 2nd Text property (forms) 2nd TextAlign property (TextBox control) 2nd TextBox control 2nd events Click MouseDown MouseMove MouseUp TextChanged maximum length of 2nd multiline text boxes 2nd 3rd 4th password fields properties Enabled 2nd MaxLength 2nd Multiline PasswordChar 2nd Scrollbars TextAlign 2nd scrollbars 2nd text alignment 2nd TextChanged event 2nd 3rd This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com TextBox control throwing exceptions time/date information adding time to 2nd DateTime data type 2nd 3rd files 2nd formatting 2nd retrieving current date/time retrieving parts of 2nd subtracting time from 2nd Timer control 2nd 3rd 4th timers creating 2nd 3rd 4th title bars forms displaying text 2nd To Grid command (Align menu) ToBoolean() method toggle buttons (toolbars) 2nd 3rd ToLongDateString() method ToLongTimeString() method tool buttons Toolbar control adding to forms 2nd drop-down menus 2nd event handling 2nd push-style buttons 2nd separators 2nd toggle buttons 2nd 3rd toolbars adding buttons 2nd 3rd adding to forms 2nd buttons moving 2nd CD/Album Catalog creating 2nd creating 2nd customizing 2nd displaying 2nd docking 2nd drop-down menus 2nd event handling 2nd hiding 2nd push-style buttons 2nd resizing 2nd restoring default settings separators 2nd toggle buttons 2nd 3rd Visual Studio NET Toolbars command (View menu) toolbox controls adding to forms 2nd form controls adding 2nd 3rd tools Object Browser 2nd 3rd pens 2nd 3rd creating This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com DashStyle property 2nd Pens class TopMost property (forms) TopMost windows creating ToShortDateString() method ToShortTimeString() method Traditional Control application trailing spaces strings deleting 2nd transparent forms creating Tree View control hierarchical lists creating 2nd nodes adding 2nd 3rd clearing removing trees hierarchical lists creating (Tree View) 2nd nodes adding (Tree View) 2nd 3rd clearing (Tree View) removing (Tree View) triggering events 2nd by object 2nd by operating system via user interaction 2nd 3rd triggering methods 2nd Trim method TrimEnd method trimming spaces in strings 2nd TrimStart method troubleshooting [See also debugging code] try statement try catch finally blocks 2nd 3rd 4th 5th type libraries referencing 2nd types 2nd (data) bool byte casting 2nd explicit implicit safe conversions 2nd char Common Type System 2nd DateTime 2nd 3rd decimal double float int long This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com object prefixes 2nd sbyte selection guidelines 2nd short string uint ulong ushort [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] UID= parameter (ConnectionString property) uint data type ulong data type underscore (_) uninstalling applications unloading forms 2nd 3rd Update() method user controls project component user interfaces [See GUIs (graphical user interfaces)] users events triggering 2nd 3rd users, interacting with controls [See controls] custom dialog boxes 2nd 3rd 4th 5th forms [See forms] keyboard input 2nd 3rd 4th 5th messages buttons 2nd DialogResult enumeration 2nd displaying 2nd guidelines 2nd icons 2nd 3rd 4th mouse events 2nd 3rd 4th 5th ushort data type using keyword [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] value, passing by variables 2nd [See also arrays] arrays referencing binding 2nd early binding 2nd 3rd late binding 2nd data types 2nd 3rd bool byte casting 2nd char decimal double float int long object prefixes 2nd sbyte selection guidelines 2nd short string uint ulong ushort declaring 2nd 3rd 4th defined in expressions 2nd literal values passing to 2nd name usage naming conventions prefixes 2nd 3rd 4th 5th scope 2nd block scope 2nd 3rd method-level scope 2nd private-level scope 2nd 3rd Vertical Spacing menu commands Decrease Make Equal View menu commands Properties Window Show Tasks Tab Order 2nd Toolbars viewers [See Picture Viewer] viewing object properties visible controls adding to forms 2nd 3rd Visual Basic NET Visual Studio Output window This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com project management projects components 2nd tasks creating 2nd deleting Task List Visual Studio NET color properties changing 2nd design windows auto hiding 2nd closed state displaying docked state docking 2nd 3rd floating floating state hidden state hiding tabbed floating windows 2nd 3rd help system accessing Dynamic Help IDE customizing navigating IDE (Integrated Development Environment) windows launching mouse double-click warning object properties changing 2nd 3rd 4th viewing project management Solution Explorer 2nd 3rd solutions 2nd projects creating 2nd 3rd file additions 2nd 3rd file removal 2nd 3rd naming 2nd opening 2nd properties, setting 2nd 3rd Properties window 2nd property descriptions Start page 2nd 3rd toolbars adding buttons to 2nd 3rd creating 2nd customizing 2nd displaying 2nd docking 2nd hiding 2nd moving buttons on 2nd resizing 2nd restoring default settings toolbox This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com control additions to forms 2nd void keyword [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] Warning value (MessageBoxIcon) Web development 2nd ASP.NET 2nd SOAP (Simple Object Access Protocol) Web Forms 2nd 3rd NET platform installation deployment graphics responsiveness security text formatting 2nd XML (eXtensible Markup Language) 2nd 3rd XML Web services 2nd 3rd Web Forms NET platform installation deployment dynamic Web content creating 2nd graphics responsiveness security text formatting 2nd Web services (XML) 2nd 3rd Web sites JamesFoxall.com Close.bmp (bitmap), downloading debugging tools 2nd Sams Publishing Close.bmp (bitmap), downloading debugging tools 2nd while loops 2nd Width property (forms) 2nd Window property (SystemColors class) windows Command window debugging features 2nd 3rd 4th design windows auto hiding 2nd closed state displaying docked state docking 2nd 3rd floating floating state hidden state hiding tabbed floating windows 2nd 3rd IDE closing positioning resizing Output Output window This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com debugging features 2nd 3rd Properties alphabetical displays categorical displays changing color properties 2nd changing object properties 2nd 3rd 4th property descriptions viewing object properties TopMost creating Windows Forms [See forms] deployment graphics responsiveness text formatting 2nd versus Web Forms WindowsDefaultBounds value (StartPosition property) WindowsDefaultLocation value (StartPosition property) WindowState property (forms) 2nd wizards Data Form Wizard 2nd 3rd 4th 5th 6th workbooks (Excel) adding data to creating with Automation 2nd worksheets (Excel) adding data to creating with Automation 2nd wrappers defined writable properties 2nd 3rd WriteLine() method 2nd 3rd writing code CD Cataloger application 2nd 3rd 4th 5th 6th 7th 8th 9th 10th GUIs 2nd 3rd 4th 5th 6th 7th 8th 9th writing [See creating] [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] X property (MouseEventsArgs object) XML (eXtensible Markup Language) ending tags semantic tags starting tags tags case sensitivity formats Web development 2nd 3rd XML (eXtensible Markup Language) Web services 2nd 3rd Xor operator (^) 2nd [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] Y property (MouseEventsArgs object) Yes value (DialogResult) YesNo value (MessageBoxButtons) YesNoCancel value (MessageBoxButtons) [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] [SYMBOL] [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Y] [Z] Z-order controls layering 2nd zero-length strings [ Team LiB ] This document is created with a trial version of CHM2PDF Pilot http://www.colorpilot.com Brought to You by Like the book? Buy it! ... of CHM2PDF Pilot http://www.colorpilot.com [ Team LiB ] • • Table of Contents Index Sams Teach Yourself Microsoft Visual C#™ NET in 24 Hours By James Foxall Publisher: Sams Publishing Pub Date:... multiple-programmer environments He is the author of numerous books, including Sams Teach Yourself C# in 24 Hours and Practical Standards for Microsoft Visual Basic NET, and he has written articles for Access-Office-VBA... an authority on application interface and behavior standards of applications for the Microsoft Windows and Microsoft Office environments James has personally written more than 200,000 lines of

Ngày đăng: 25/03/2019, 15:40