did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9780321268921

Data Binding with Windows Forms 2.0 Programming Smart Client Data Applications with .NET

by
  • ISBN13:

    9780321268921

  • ISBN10:

    032126892X

  • Edition: 1st
  • Format: Paperback
  • Copyright: 2006-01-12
  • Publisher: Addison-Wesley Professional
  • Purchase Benefits
List Price: $64.99 Save up to $5.38
  • Digital
    $59.61
    Add to Cart

    DURATION
    PRICE

Supplemental Materials

What is included with this book?

Summary

Data binding is the most important part of many business applications-and one of the most difficult things to understand. Data Binding with Windows Forms 2.0 is the first book to focus on this crucial area of development. It will quickly get you up to speed on binding data sources to Windows Forms components. The book contains clear examples in C# that work with SQL Server 2000 and SQL Server 2005. Visual Basic .NET examples are available on the book's Web site.

Author Biography

Brian Noyes is a software architect, trainer, writer, and speaker with IDesign, a premier .NET architecture and design consulting and training company

Table of Contents

Foreword xxi
Preface xxiii
Acknowledgments xxxv
About the Author xxxvii
1 Building Data-Bound Applications with Windows Forms
1(30)
What Is Data Binding?
2(1)
Your First Data-Bound Windows Forms 2.0 Application
3(28)
Creating a Windows Application Project
4(2)
Adding a New Data Source and a Data Connection
6(2)
Selecting Data Objects
8(2)
Customizing Data Sources Control Mappings
10(1)
Generating Data-Bound Controls
11(2)
Running the Application
13(1)
Data-Binding Landscape
14(1)
Data Sources
15(1)
Data Objects and Collections
16(2)
DataSets or Not, That Is the Question...
18(2)
Data-Bound Controls
20(1)
Layered Application Architecture
21(6)
What Is a Smart Client?
27(1)
Where Are We?
28(3)
2 Working with Typed Data Sets and Table Adapters
31(50)
A Quick Review of DataSets
31(3)
The Quest for Type Safety
34(3)
Typed Data Set Internals
37(4)
Creating Typed Data Sets
41(1)
Creating Typed Data Sets with the Data Set Designer
42(7)
Creating a Typed Data Set and Setting Up a Data Connection
43(5)
Adding Tables to a Data Set
48(1)
Typed Data Set-Generated Code
49(3)
Introduction to Table Adapters
52(4)
Filling and Updating a Typed Data Set with a Table Adapter
56(2)
Connection Management
58(4)
Adding Transaction Support to a Table Adapter
62(4)
Adding Helper Data Access Methods
66(1)
Basing Table Adapters on Stored Procedures or Views
67(2)
Adding Queries to Table Adapters
69(8)
Adding a Custom Query to a Table Adapter
69(3)
Using the Query Builder to Write a SQL Statement
72(2)
Configuring a Table Adapter to Use Stored Procedures
74(3)
Creating Typed Data Sets with Command Line Tools
77(1)
Using Typed Data Sets in Your Code
78(1)
Where Are We?
79(2)
3 Introducing Data Binding in Windows Forms
81(30)
The 40,000-Foot View of Data Binding
81(5)
Data Binding Concepts
82(2)
.NET Framework 2.0 Data Binding Enhancements
84(2)
Binding Data Collections to a Grid
86(2)
Binding Data Collections to Multi-Valued Controls
88(2)
Binding Data to Individual Controls on a Form
90(2)
Data Paths Within Data Sources
92(4)
Synchronizing Data Between Controls
96(1)
Smarter Data Containment
97(2)
Paging Through Data
99(5)
Master-Details Data Binding
104(2)
Updating Data Sources Through Data Binding
106(2)
Where Are We?
108(3)
4 Binding Controls to Data Sources in Getting to Know the BindingSource Component
111(66)
Simple Data Binding with Binding Sources
112(4)
Chaining Binding Sources for Master-Details Data Binding
116(5)
Navigating Data Through a Binding Source
121(1)
Manipulating Data Through a Binding Source
122(2)
Using a Binding Source as a Data Storage Container
124(2)
Filling a Binding Source with a Data Reader
126(2)
Sorting, Searching, and Filtering Presented Data with a Binding Source
128(3)
Monitoring the Data with Events
131(2)
Restricting Changes to the Data
133(1)
Underneath the Covers of Data Binding for Complex Types
134(7)
Binding an Image Column to a PictureBox Control
141(1)
Binding a DateTime Column to a DateTimePicker
142(2)
Binding a DateTime Column to a TextBox
144(1)
Binding a Numeric Column to a TextBox
145(2)
Automatic Formatting and Parsing Summary
147(1)
Going Beyond Built-In Type Conversion with Binding Events
148(6)
Handling the Format Event
154(2)
Handling the Parse Event
156(1)
Completing the Editing Process
157(3)
Making the User's Life Easier with AutoComplete
160(2)
Data Binding Lifecycle
162(1)
Smarter Child-Parent Data Binding
163(2)
Binding to Multiple Copies of Data
165(3)
Updating Parent Data-Bound Controls from Child Data-Bound Controls
168(4)
Synchronizing Many-to-Many Related Collections
172(4)
Where Are We?
176(1)
5 Generating Bound Controls with the Visual Studio Designer
177(40)
Working with the Data Sources Window
177(2)
Adding Data Sources to a Project
179(1)
Choosing the Type of Data Source
180(1)
Adding a Database Data Source
181(4)
Adding a Web Service Data Source
185(1)
Adding an Object Data Source
186(3)
Generating Bound Controls from Data Sources
189(7)
Selecting the Bound Control Type
196(1)
Customizing the Bound Control Types
196(3)
Binding Existing Controls to Data Sources
199(3)
Behind the Scenes: Designer Code and Data Sources Files
202(3)
Other Designer Data-Binding Code Generation
205(1)
Setting Control Data Binding Through the Properties Window
206(4)
Generating Data Bindings with Smart Tags
210(4)
Generating Master-Details Data-Bound Controls with the Designer
214(2)
Where Are We?
216(1)
6 Presenting Data with the DataGridView Control
217(68)
DataGridView Overview
218(1)
Basic Data Binding with the DataGridView
219(2)
Controlling Modifications to Data in the Grid
221(1)
Programmatic DataGridView Construction
222(4)
Programmatically Adding Columns to a Grid
222(2)
Programmatically Adding Rows to a Grid
224(2)
Custom Column Content with Unbound Columns
226(7)
Displaying Computed Data in Virtual Mode
233(8)
Setting Up Virtual Mode
234(4)
Initializing the Grid
238(1)
Understanding Virtual Mode Behavior
239(1)
Virtual Mode Summary
240(1)
Using the Built-In Column Types
241(14)
DataGridViewTextBoxColumn
249(1)
DataGridViewButtonColumn
250(1)
DataGridViewLinkColumn
250(1)
DataGridViewCheckBoxColumn
251(1)
DataGridViewlmageColumn
251(1)
DataGridViewComboBoxColumn
252(3)
Built-In Header Cells
255(1)
Handling Grid Data Edits
256(3)
Automatic Column Sizing
259(3)
Column and Row Freezing
262(1)
Using the Designer to Define Grids
263(3)
Column Reordering
266(3)
Defining Custom Column and Cell Types
269(8)
Defining a Custom Cell Type
270(3)
Defining a Custom Column Type
273(4)
Utilizing Cell-Oriented Grid Features
277(4)
Formatting with Styles
281(3)
Where Are We?
284(1)
7 Understanding Data-Binding Interfaces
285(58)
What Does Data Binding Have to Do with Interfaces?
286(3)
The IEnumerable and IEnumerator Interfaces: Supporting Iteration Through Collections
289(6)
The ICollection Interface: Controlling Access to a Collection
295(3)
The IList Interface: Enabling Data Binding
298(5)
The IListSource Interface: Exposing Collections of Collections
303(2)
Property Descriptors: Allowing Dynamic Data Item Information Discovery
305(2)
The ITypedList Interface: Exposing Data-Binding Properties
307(3)
The IBindingList Interface: Providing Rich Binding Support
310(13)
Getting to Know the IBindingList Members
310(3)
Notifying Consumers of Changes to the Collection
313(3)
Exercising IBindingList Change Notifications
316(1)
Supporting Sorting with IBindingList
317(5)
Supporting Searching with IBindingList
322(1)
The IBindingListView Interface: Supporting Advanced Sorting and Filtering
323(2)
The ICancelAddNew Interface: Supporting Transactional Inserts in a Collection
325(2)
The IRaiseltemChangedEvents Interface: Providing Item Modification Notifications on Collections
327(1)
The IEditableObject Interface: Supporting Transactional Item Modifications
328(1)
The INotifyPropertyChanged Interface: Publishing Item Change Notifications
329(1)
The IDataErrorInfo Interface: Providing Error Information
330(2)
The ICustomTypeDescriptor Interface: Exposing Custom Type Information
332(2)
The ISupportInitialize Interface: Supporting Designer Initialization
334(3)
The ISupportInitializeNotification Interface: Supporting Interdependent Component Initialization
337(4)
The ICurrencyManagerProvider Interface: Exposing a Data Container's CurrencyManager
341(1)
Where Are We?
341(2)
8 Implementing Custom Data-Bound Controls
343(56)
Extending Framework Data-Bound Controls
344(1)
Creating a Grouped Column DataGridView
345(5)
Deriving from DataGridView and Handling the CellFormatting Event
347(1)
Modifying the Painting Behavior of the Cell
348(2)
Using Custom Controls
350(2)
The User Control Test Container
352(1)
Developing Data-Bound Container Controls
353(1)
Building a Filtered Grid Control
354(3)
Adding Data-Binding Capability to a Custom Control
357(2)
Supporting Designer Initialization of Data Binding
359(1)
Specifying Binding Properties on a Control
360(2)
Supporting Delayed Initialization with ISupportInitialize
362(5)
Dynamically Determining the Properties of a Data Source
367(4)
Dynamically Populating a Combo Box Control
368(2)
Handling the ListChanged Event
370(1)
Autocompleting Input in a TextBox Control
371(4)
Autosizing Columns in the Grid
375(1)
Winding Up the Filtered Grid Example
376(3)
Building a Custom Data-Bound Control from Scratch
379(1)
Building a Data-Bound Charting Control for Decision Support
379(5)
Creating a Custom Control That Draws Itself
381(2)
Defining a Custom Data Structure for Rendering
383(1)
Coding a Data-Bound Custom Control
384(7)
Defining the Custom Control Skeleton
385(2)
Initializing and Updating the Data Bindings
387(2)
Adding Bar Chart Instances to the Container
389(2)
Adding Editing Support to a Custom Data Bound Control
391(6)
Where Are We?
397(2)
9 Implementing Custom Data-Bound Business Objects and Collections
399(58)
Defining and Working with Data-Bound Business Objects
400(5)
Defining and Working with Data-Bound Business Object Collections
405(1)
.NET Framework Generic Collection Classes
406(2)
The CustomBusinessObjects Example
408(7)
Binding the Customers and Orders Objects to Form Controls
410(3)
Generating Some Test Data to Bind Against
413(2)
Setting the Textual Data-Binding Behavior of Custom Objects
415(1)
Supporting Transacted Object Editing with IEditableObject
416(4)
Supporting Object Edit Notifications with Property Change Events
420(3)
Supporting Object Edit Notifications with INotifyPropertyChanged
423(4)
Using BindingList[T> to Create Rich Object Collections 424
Creating a Custom Collection Type Based on BindingList[T> 426
Taking Over the Construction Process
427(2)
Getting Some Test Data to Work With
429(1)
Adding Search Functionality to the Collection
430(2)
Adding Sorting Capabilities to the Collection
432(7)
Managing Transacted Additions to a Collection
439(2)
Raising Item Changed Events
441(2)
Adding IBindingListView Functionality
443(10)
Binding to Business Objects Through the Data Sources Window
453(2)
Where Are We?
455(2)
10 Validating Data Input and Handling Errors 457(30)
Windows Forms Validation
458(1)
Handling Validation Events
459(3)
DataGridView Validation Events
462(1)
Validation Up the Control Hierarchy
463(1)
Displaying Validation Errors with the ErrorProvider Control
464(3)
DataGridView Error Displays
467(1)
DataGridView DataError Event
468(3)
Controlling Validation Behavior with the AutoValidate Property
471(1)
Validation down the Control Hierarchy
472(2)
Extended Validation Controls
474(1)
Capturing Data Errors on Data Sets
475(4)
Providing Error Information from Custom Objects with IDataErrorinfo
479(4)
Data Concurrency Resolution
483(1)
Where Are We?
484(3)
A Binding to Data in ASP.NET 487(34)
ASP.NET Page Processing Basics
489(1)
Data Binding in ASP.NET 1.X
490(8)
Presenting Tabular Data in a Grid
491(1)
Hooking Up Dynamic Behavior in a Code-Behind Class
492(3)
Handling Row Selecting in the Grid
495(1)
Using Data-Binding Expressions
496(2)
Data-Binding Overview in ASP.NET 2.0
498(1)
Data Sources
499(9)
SqlDataSource Control
500(5)
ObjectDataSource Control
505(2)
AccessDataSource Control
507(1)
XmlDataSource Control
507(1)
SiteMapDataSource Control
508(1)
Data-Binding Expressions
508(1)
GridView Control
509(3)
DetailsView Control
512(2)
FormView Control
514(1)
Master-Details Binding
515(3)
Hierarchical Binding
518(1)
Where Are We?
519(2)
B Binding Data in WinFx Applications 521(26)
WinFx UI Programming and Capabilities Overview
522(3)
Writing a Simple WinFx Application
525(7)
Getting Started with a "Hello World" Application
526(2)
Building a Slightly More Involved Application
528(4)
WinFx Data Binding 101
532(4)
Data Contexts and Data Sources
536(1)
What About XAML?
537(4)
Binding a Collection to a Grid with Templates
541(2)
Control Styling in WinFx
543(2)
Where Are We?
545(2)
C Programming Windows Forms Applications 547(56)
Your First Windows Forms Data Application
548(6)
Creating Windows Forms Applications with Visual Studio
554(9)
Creating an Empty Windows Forms Project
554(1)
Working with the Toolbox
555(2)
Adding Members to the Form
557(4)
Hooking Up an Event Handler and Data Binding
561(2)
Windows Forms Designer-Generated Code (New in 2.0)
563(4)
A Brief Tour of the Windows Forms Architecture
567(3)
The Dawn of .NET Execution—The Main Method
570(4)
Handling Control Events
574(2)
Displaying Other Forms
576(1)
Containing Forms Within a Parent Form
577(1)
Common Data Display Controls
578(8)
Label Controls
579(1)
Button Controls
580(1)
Check Box Controls
580(1)
Radio Button Controls
581(1)
Text Box Controls
581(1)
RichTextBox Controls
582(1)
DateTimePicker Controls
582(1)
List Box Controls
582(2)
Combo Box Controls
584(1)
List View Controls
584(1)
Tree View Controls
585(1)
Picture Box Controls
585(1)
Data Grid Controls
585(1)
DataGridView Controls (New in 2.0)
586(1)
Creating a Custom User Control
586(3)
Laying Out Controls on a Form
589(7)
Absolute Positioning and Sizing of Controls
589(1)
Anchoring Controls
590(2)
Docking Controls
592(3)
Using Layout Container Controls (New in 2.0)
595(1)
Setting Tab Order
596(2)
Command and Control of Your Windows Forms Applications (New in 2.0)
598(2)
Where Are We?
600(3)
D Accessing Data with ADO.N ET 6oi Relational Data Access 603(68)
The Ubiquitous DataSet
607(2)
Loading Data Sets from a File
609(2)
Creating a Data Set Programmatically
611(2)
Loading Data Sets from a Database
613(6)
Loading a DataTable with a DataReader
619(2)
Master-Details DataSets
621(2)
Retrieving Data with Stored Procedures
623(1)
Updating the Database Using Data Sets
624(4)
Handling Concurrency
628(4)
Updating with Data Sets and Stored Procedures
632(5)
Searching Data Sets
637(2)
Merging Data from Multiple Data Sets
639(2)
Working with Data Views
641(2)
Working with Transactions
643(4)
Scoping Transactions with System.Transactions
647(3)
Client-Side Transactions
650(1)
Data Set and Data Adapter Events
651(3)
Reading Data into Business Objects
654(4)
XML Data Access
658(1)
Working with the XmlDataDocument Class
659(4)
Working with the XPathDocument Class
663(1)
Loading Data into an XPathDocument
664(1)
Querying XML Data
665(2)
Navigating an XML Document
667(3)
Where Are We?
670(1)
Index 671

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Excerpts

When I first started discussing this book with the editors at Addison-Wesley, I was a little skeptical. My gut reaction was, "Will anyone need a whole book focused on data binding?" I mean, Windows Forms is just GUI stuff, right? You drag this, you drop that, you hook up a few event handlers, and you move on to build the rest of your enterprise applicationall the middle-tier goo that ties your head in knots. As I thought more about it, I realized that a significant percentage of the work that people do in Windows Forms applications is centered around data binding, and most of the problems developers encounter are related to getting data-binding scenarios to work correctly. Add to that the multitude of new capabilities in Windows Forms 2.0 and Visual Studio 2005 related to data binding, and I quickly became convinced that this book would be a good idea. Hopefully you will agree after you have finished reading it. Data binding is a powerful capability that has finally matured in Windows Forms 2.0 through the capabilities in the .NET Framework classes, combined with the rich designer support provided by Visual Studio 2005. By using data binding properly, you can save yourself from writing a lot of unnecessary code, provide your users a rich interactive experience for working with data that functions well, and produce code that is easy to maintain. To get it working correctly across a variety of use cases, you need to know more than how to set a few properties on controlsyou need to understand what is going on under the hood, especially if you want tosupport complex scenarios that require going beyond the basic capabilities of the data-binding components in the .NET Framework. Due to the growth of smart client architecture, Windows Forms applications are becoming more prominent in business systems. Web browser-based applications leave a lot to be desired; they cannot support many of today's common scenarios. They don't harness the capabilities of the client machine, and they are constrained by the request-response model of browser-based applications and the connectivity issues that surround them. So the importance of being able to code complex data application scenarios in Windows Forms is growing, and luckily the capabilities in .NET services are rapidly maturing to keep pace. Who Should Read This Book? The primary audience for this book is intermediate to advanced Windows Forms developers who want to learn about the new data-binding features in Windows Forms 2.0 and refine their coding practices for data-bound applications. This book dives deep into advanced features of the data-binding mechanisms in Windows Forms, data-bound controls, working with data sources, and creating custom data-bound objects and collections. If you spend a significant amount of time working with data in Windows Forms applications, then this book is for you. If you are a beginner Windows Forms developer, this book will help you quickly learn how to support data binding. Many of the features in Windows Forms 2.0 take developers through wizards and designer features that are helpful for beginning programmers, and you will learn about those features in this book. In addition, Appendixes C and D are geared for beginner programmers to get up to speed on the basics of Windows Forms and data access. Conventions Developing applications is more about tools and less about code. However, there is a lot of code in this book, and I have adopted some common conventions to help make things easier. References to classes, variables, namespaces, and other artifacts that manifest themselves in code are in a monospace font; this helps you distinguish an instance of the DataSet class from a conceptual discussion of data sets. Short code listings are presented inline within the text using a different

Rewards Program