Contents
INTRODUCTION xxv
the Visual studioseCtion i: ide and Controls
GettinG started with the Visual studio ide lesson 1: 3
Installing C# 4
Configuring the IDE 5
Building Your First Program 5
Copying Projects 9
Exploring the IDE 10
Try It 13
Lesson Requirements 14
Hints 14
Step-by-Step 14
Exercises 17
CreatinG Controls 1lesson 2: 9
Understanding Controls 19
Properties 20
Methods 20
Events 20
Creating Controls 21
Setting Control Properties 22
Control Names 23
Popular Properties 24
Modifying Properties in Code 26
Arranging Controls 27
Snap Lines 27
Arrow Keys 28
The Format Menu and Layout Toolbar 28
Try It 29
Lesson Requirements 30
Hints 30
Step-by-Step 30
Exercises 34
596906ftoc.indd 11 4/7/10 12:31:12 PM
xii
CONTENTS
MakinG Controls arranGe theMselVes 3lesson 3: 7
Restricting Form Size 38
Using Anchor Properties 38
Using Dock Properties 40
Try It 42
Lesson Requirements 42
Hints 43
Step-by-Step 43
Exercises 44
handlinG eVents 4lesson 4: 7
Making Event Handlers 47
Using Event Parameters 48
Tracking Mouse Movement 49
Detecting Mouse Clicks 49
Removing Event Handlers 50
Adding and Removing Event Handlers in Code 50
Useful Events 51
Try It 52
Lesson Requirements 53
Hints 53
Step-by-Step 53
Exercises 54
MakinG Menus 5lesson 5: 7
Creating Menus 57
Setting Menu Properties 58
Handling Menu Events 59
Creating Context Menus 60
Try It 60
Lesson Requirements 61
Hints 61
Step-by-Step 61
Exercises 64
MakinG tool strips and status strips 6lesson 6: 7
Using Tool Strips 67
Using Tool Strip Containers 69
Using Status Strips 70
596906ftoc.indd 12 4/7/10 12:31:12 PM
xiii
CONTENTS
Try It 71
Lesson Requirements 71
Hints 73
Step-by-Step 73
Exercises 76
usinG riChtextBoxes 7lesson 7: 9
Using RichTextBox Properties 79
Giving the User Control 81
Using RichTextBox Methods 82
Try It 84
Lesson Requirements 85
Hints 85
Step-by-Step 85
Exercises 86
usinG standard dialoGs 8lesson 8: 9
Using Dialogs in General 90
Adding the Dialog to the Form 91
Initializing the Dialog 91
Displaying the Dialog and Checking the Return Result 92
Processing the Results 93
Putting It All Together 93
Using Dialog Properties 93
Using File Filters 96
Try It 98
Lesson Requirements 98
Hints 99
Step-by-Step 99
Exercises 101
CreatinG and displayinG new ForMs 10lesson 9: 3
Adding New Forms 103
Understanding Classes and Instances 104
Displaying Forms 105
Controlling Remote Forms 107
Try It 109
Lesson Requirements 109
Hints 110
Step-by-Step 110
Exercises 112
596906ftoc.indd 13 4/7/10 12:31:12 PM
xiv
CONTENTS
BuildinG CustoM dialoGs 11lesson 10: 5
Making Custom Dialogs 115
Setting the Dialog Result 116
Using Custom Dialogs 117
Try It 118
Lesson Requirements 118
Hints 119
Step-by-Step 119
Exercises 121
VariaBles and CalCulationseCtion ii: s
usinG VariaBles and perForMinG CalCulations 12lesson 11: 7
What Are Variables? 127
Data Types 127
Float, Double, and Decimal Data Types 129
Declaring Variables 130
Literal Values 131
Type Conversions 133
Casting 134
Converting 135
Parsing 135
Performing Calculations 136
Operands and Operators 137
Promotion 137
Operator Summary 137
Precedence 143
Constants 145
Try It 145
Lesson Requirements 146
Hints 146
Step-by-Step 146
Exercises 148
deBuGGinG Code 15lesson 12: 1
Deferred Techniques 151
Debugging Then and Now 152
Setting Breakpoints 152
Reading Variables 153
Stepping Through Code 154
Using Watches 155
596906ftoc.indd 14 4/7/10 12:31:12 PM
xv
CONTENTS
Using the Immediate Window 156
Try It 157
Lesson Requirements 158
Step-by-Step 158
Exercises 161
understandinG sCope 16lesson 13: 3
Scope Within a Class 163
Same Named Variables 164
Method Variable Lifetime 165
Block Scope 166
Accessibility 167
Restricting Scope and Accessibility 168
Try It 168
Lesson Requirements 169
Hints 169
Step-by-Step 169
Exercises 171
workinG with strinGs 17lesson 14: 5
String Methods 175
Format and ToString 177
Standard Numeric Formats 179
Custom Numeric Formats 180
Standard Date and Time Formats 181
Custom Date and Time Formats 182
Try It 184
Lesson Requirements 184
Hints 184
Step-by-Step 185
Exercises 185
workinG with dates and tiMes 18lesson 15: 7
Creating DateTime Variables 187
Local and UTC Time 188
DateTime Properties and Methods 188
TimeSpans 190
Try It 191
Lesson Requirements 192
Hints 192
Step-by-Step 192
Exercises 194
596906ftoc.indd 15 4/7/10 12:31:12 PM

Get Stephens' C# Programming with Visual Studio® 2010 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.