Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Visual CSharp 2005 Express Edition (2006) [eng]

.pdf
Скачиваний:
42
Добавлен:
16.08.2013
Размер:
9.96 Mб
Скачать

Acknowledgements

Anytime you create a book that is shipping day and date with a product such as this one did, the project is much more complicated because of dealing with beta product right up until the end. There are a number of people I want to thank who have been working hard with me on this book for Wrox, including the following people who are at Wrox: Katie Mohr, who is the nicest acquisition editor (sorry Jim) there is.

She can nag you about a deadline, and you thank her. Howard Jones, a great development editor who would put up with my late night submissions, and still made me look good. Felicia Robinson, the production editor who came in late in the process when we were short on patience, and made things easy for us.

I also want to thank Karli Watson, for taking the time to tech edit my book when I know he is busy with so much of his own work. I am honored to have you work on this book Karli.

Many thanks to Dan Fernandez, who is on the Microsoft C# Express team and Suzanna Moran, my MVP lead at Microsoft, for answering my many questions and making sure I had what I need to get this book done. Dan, you have a great amount of patience, and Suzanna, you rock when it comes to getting me connected with the right people.

As usual, my family has put up with me writing yet another book: Chris 17, Kari Anne 15, Nichole 12, David 10, Joseph 4, and my awesome wife Diana.

Dedication

To my beautiful and brilliant wife and friend, Diana. Besides being a strong woman of God who also demonstrates her belief in me every day, I can’t think of anyone I would rather have by my side for the rest of my life, to guide my kids, and share many beautiful sunsets with.

Contents

About the Author

v

Acknowledgments

ix

Introduction

xix

Part I: Introduction and Concepts

1

Chapter 1: Starting Strong with Visual C# 2005 Express Edition

3

What Is Microsoft Visual C# 2005 Express?

4

The Differences between C# and C# Express

4

Members of the Express Series

4

Overview of C# Express Development Environment

9

What Is the IDE (Integrated Development Environment)?

9

Taking a Look at the C# Express Start Page

10

Tools of the C# Express IDE

15

Structure of C# Express Solutions and Projects

16

Summary

18

Exercises

19

Chapter 2: Programming 101: A Quick Discussion

21

What Is Programming?

21

General Programming Overview

22

Hardware versus Software

22

Programming Then and Now

22

Compiled versus Interpreted

23

What about OOP?

24

Introduction to Windows Programming

25

Different Levels of Programming

25

Event Programming

26

Dynamic-Link Libraries

26

Summary

27

Exercises

27

Contents

Chapter 3: Quick Start Creating Your First C# Express Windows Project

29

Which Type of Application to Create: Windows or Console?

30

Differences between Using Windows and Console Applications

30

Purposes for Using Windows and Console Applications

30

Getting Started with Windows Application Projects

31

Setting the IDE up for a Windows Application Project

32

Overview of the Solution Explorer

37

Discussion about Properties

39

Adding Controls to the Form

41

Working with Code on an Event

46

Summary

49

Exercises

50

Chapter 4: Introducing .NET

51

Introduction to .NET Framework

51

Common Language Runtime

53

.NET Framework Class Library

53

Working with .NET Namespaces

55

Object Browser: Tool of the Namespace Trade

55

Supplying the Fully Qualified Namespace

59

The Using Directive

61

Summary

64

Exercises

65

Chapter 5: Getting into C# Types

67

What Are Variables and Constants?

67

Declaring and Assigning C# Variables

68

Standard C# Types

73

Naming C# Variables

76

Converting between Variable Types

77

Enumerations

79

Using C# Constants

80

Summary

80

Exercises

80

Chapter 6: Debugging Applications in C# Express

81

What is Debugging in C# Express?

82

Types of Errors That Can Occur in Your Applications

82

C# Express Debugging Features: Tools of the Trade

82

xiv

 

Contents

Working with Breakpoints

86

Edit and Continue Feature in C# Express

87

Displaying and Modifying Variables when in Break Mode

89

Using IntelliSense

89

Additional Ways of Displaying Variables

90

Locals Window

90

Immediate Window

91

Watch Window

92

Additional Windows

92

Stepping through Code

92

Other Debugging Tools

93

Summary

94

Exercises

95

Chapter 7: Selections, Iterations, and Catching Exceptions

97

Performing Selections in Your Applications

98

Creating the Chapter 7 Project

98

Simple Selection Using if...else Statements

99

Working with switch . . . case Statements

104

Performing Iterations

109

Working with for Statements

109

Handling Objects with foreach Statement

111

Using do and while Statements

112

Catching Exceptions in Your Code

115

Starting Off Easy with try...catch Statements

116

Using the finally Statement

118

Summary

121

Exercises

121

Part II: Creating Applications with C# Express

123

Chapter 8: Working with Forms and Controls

125

Creating User Interfaces Using Windows Standards

125

Use of Switchboards

126

Form Application Types and Standards

127

Looking at Forms

128

Form Properties

128

Controls Overview

137

Control Properties

138

The MenuStrip Control

138

Moving, Aligning, and Resizing Controls

141

xv

Contents

Working with MDI Forms

144

The MDI Form Property

144

The MDI Line of Code

145

The Optional MDI Menu Property

145

Summary

147

Exercises

148

Chapter 9: Adding Dialog Boxes and Rich Text to Your Application

149

Introducing the Application

149

Working with the RichTextBox Control

153

Docking the RichTextBox Control

153

Some Other RichTextBox Control Properties

155

Introducing the Dialog Controls

158

Using the ColorDialog Control

158

Using the FontDialog Control

160

Using the OpenFileDialog Control

162

Using the SaveFileDialog Control

164

Summary

165

Exercises

166

Part III: Using Data in Applications

167

Chapter 10: Introducing Database Concepts

169

Getting Started with Databases

169

Looking at Databases in the Real World

170

Database Models

171

Relational Database Model

172

Working with Various Databases

176

File Server versus Client/Server

176

Front and Back Ends

176

Microsoft Access

176

Microsoft SQL Server

178

Summary

179

Exercises

179

Chapter 11: Using SQL Server Express Features within C# Express

181

Introducing SQL Server Express

181

Access to SQL Server

182

SQL Server Configuration Manager

182

xvi

 

Contents

SQL Server Tools in C# Express

183

Introducing the Database Explorer

183

Summary

192

Exercises

193

Chapter 12: Utilizing .NET Data Controls

195

Getting Started Using Data in Your Applications

195

Starting with Data Sources

196

Data Controls Overview

199

Using the DataGridView Control

199

Creating a DataGridView with Single Record Display

202

BindingNavigator Control

202

Summary

205

Exercises

205

Chapter 13: Working with ADO.NET

207

Introducing ADO.NET

207

Some Data Access History

208

Welcome ADO.NET

208

Using ADO.NET Classes in Your Application

209

Populating a ListBox Control

210

Adding a DataGridView Control

212

Executing Parameterized Stored Procedures using the SqlCommand Class

214

Summary

217

Exercises

217

Part IV: Finishing Touches

219

Chapter 14: Getting More Experience with Controls

221

Walking through the Demo Application

222

Demo 1: Browsing Web Files

222

Demo 2: Choosing and Displaying Dates

222

Demo 3: Working with Progress and Status Bars

224

Getting Started with the Tab Control

224

Displaying Files in a Web Browser

228

Controls Used for the Demonstration

228

Adding the Code for Browsing and Displaying Files

231

Working with Date Controls

239

Looking at the MonthCalendar Control

240

Looking at the DateTimePicker Control

241

xvii

Соседние файлы в предмете Программирование на C++