Contents

Foreword

Preface

Acknowledgments

About the Author

1 Building Data-Bound Applications with Windows Forms

What Is Data Binding?

Your First Data-Bound Windows Forms 2.0 Application

Creating a Windows Application Project

Adding a New Data Source and a Data Connection

Selecting Data Objects

Customizing Data Sources Control Mappings

Generating Data-Bound Controls

Running the Application

Data-Binding Landscape

Data Sources

Data Objects and Collections

DataSets or Not, That Is the Question...

Data-Bound Controls

Layered Application Architecture

What Is a Smart Client?

Where Are We?

2 Working with Typed Data Sets and Table Adapters

A Quick Review of DataSets

The Quest for Type Safety

Typed Data Set Internals

Creating Typed Data Sets

Creating Typed Data Sets with the Data Set Designer

Creating a Typed Data Set and Setting Up a Data Connection

Adding Tables to a Data Set

Typed Data Set-Generated Code

Introduction to Table Adapters

Filling and Updating a Typed Data Set with a Table Adapter

Connection Management

Adding Transaction Support to a Table Adapter

Adding Helper Data Access Methods

Basing Table Adapters on Stored Procedures or Views

Adding Queries to Table Adapters

Adding a Custom Query to a Table Adapter

Using the Query Builder to Write a SQL Statement

Configuring a Table Adapter to Use Stored Procedures

Creating Typed Data Sets with Command Line Tools

Using Typed Data Sets in Your Code

Where Are We?

3 Introducing Data Binding in Windows Forms

The 40,000-Foot View of Data Binding

Data Binding Concepts

.NET Framework 2.0 Data Binding Enhancements

Binding Data Collections to a Grid

Binding Data Collections to Multi-Valued Controls

Binding Data to Individual Controls on a Form

Data Paths Within Data Sources

Synchronizing Data Between Controls

Smarter Data Containment

Paging Through Data

Master-Details Data Binding

Updating Data Sources Through Data Binding

Where Are We?

4 Binding Controls to Data Sources

Getting to Know the BindingSource Component

Simple Data Binding with Binding Sources

Chaining Binding Sources for Master-Details Data Binding

Navigating Data Through a Binding Source

Manipulating Data Through a Binding Source

Using a Binding Source as a Data Storage Container

Filling a Binding Source with a Data Reader

Sorting, Searching, and Filtering Presented Data with a Binding Source

Monitoring the Data with Events

Restricting Changes to the Data

Underneath the Covers of Data Binding for Complex Types

Binding an Image Column to a PictureBox Control

Binding a DateTime Column to a DateTimePicker

Binding a DateTime Column to a TextBox

Binding a Numeric Column to a TextBox

Automatic Formatting and Parsing Summary

Going Beyond Built-In Type Conversion with Binding Events

Handling the Format Event

Handling the Parse Event

Completing the Editing Process

Making the User’s Life Easier with AutoComplete

Data Binding Lifecycle

Smarter Child-Parent Data Binding

Binding to Multiple Copies of Data

Updating Parent Data-Bound Controls from Child Data-Bound Controls

Synchronizing Many-to-Many Related Collections

Where Are We?

5 Generating Bound Controls with the Visual Studio Designer

Working with the Data Sources Window

Adding Data Sources to a Project

Choosing the Type of Data Source

Adding a Database Data Source

Adding a Web Service Data Source

Adding an Object Data Source

Generating Bound Controls from Data Sources

Selecting the Bound Control Type

Customizing the Bound Control Types

Binding Existing Controls to Data Sources

Behind the Scenes: Designer Code and Data Sources Files

Other Designer Data-Binding Code Generation

Setting Control Data Binding Through the Properties Window

Generating Data Bindings with Smart Tags

Generating Master-Details Data-Bound Controls with the Designer

Where Are We?

6 Presenting Data with the DataGridView Control

DataGridView Overview

Basic Data Binding with the DataGridView

Controlling Modifications to Data in the Grid

Programmatic DataGridView Construction

Programmatically Adding Columns to a Grid

Programmatically Adding Rows to a Grid

Custom Column Content with Unbound Columns

Displaying Computed Data in Virtual Mode

Setting Up Virtual Mode

Initializing the Grid

Understanding Virtual Mode Behavior

Virtual Mode Summary

Using the Built-In Column Types

DataGridViewTextBoxColumn

DataGridViewButtonColumn

DataGridViewLinkColumn

DataGridViewCheckBoxColumn

DataGridViewImageColumn

DataGridViewComboBoxColumn

Built-In Header Cells

Handling Grid Data Edits

Automatic Column Sizing

Column and Row Freezing

Using the Designer to Define Grids

Column Reordering

Defining Custom Column and Cell Types

Defining a Custom Cell Type

Defining a Custom Column Type

Utilizing Cell-Oriented Grid Features

Formatting with Styles

Where Are We?

7 Understanding Data-Binding Interfaces

What Does Data Binding Have to Do with Interfaces?

The IEnumerable and IEnumerator Interfaces: Supporting Iteration Through Collections

The ICollection Interface: Controlling Access to a Collection

The IList Interface: Enabling Data Binding

The IListSource Interface: Exposing Collections of Collections

Property Descriptors: Allowing Dynamic Data Item Information Discovery

The ITypedList Interface: Exposing Data-Binding Properties

The IBindingList Interface: Providing Rich Binding Support

Getting to Know the IBindingList Members

Notifying Consumers of Changes to the Collection

Exercising IBindingList Change Notifications

Supporting Sorting with IBindingList

Supporting Searching with IBindingList

The IBindingListView Interface: Supporting Advanced Sorting and Filtering

The ICancelAddNew Interface: Supporting Transactional Inserts in a Collection

The IRaiseItemChangedEvents Interface: Providing Item Modification Notifications on Collections

The IEditableObject Interface: Supporting Transactional Item Modifications

The INotifyPropertyChanged Interface: Publishing Item Change Notifications

The IDataErrorInfo Interface: Providing Error Information

The ICustomTypeDescriptor Interface: Exposing Custom Type Information

The ISupportInitialize Interface: Supporting Designer Initialization

The ISupportInitializeNotification Interface: Supporting Interdependent Component Initialization

The ICurrencyManagerProvider Interface: Exposing a Data Container’s CurrencyManager

Where Are We?

8 Implementing Custom Data-Bound Controls

Extending Framework Data-Bound Controls

Creating a Grouped Column DataGridView

Deriving from DataGridView and Handling the CellFormatting Event

Modifying the Painting Behavior of the Cell

Using Custom Controls

The User Control Test Container

Developing Data-Bound Container Controls

Building a Filtered Grid Control

Adding Data-Binding Capability to a Custom Control

Supporting Designer Initialization of Data Binding

Specifying Binding Properties on a Control

Supporting Delayed Initialization with ISupportInitialize

Dynamically Determining the Properties of a Data Source

Dynamically Populating a Combo Box Control

Handling the ListChanged Event

Autocompleting Input in a TextBox Control

Autosizing Columns in the Grid

Winding Up the Filtered Grid Example

Building a Custom Data-Bound Control from Scratch

Building a Data-Bound Charting Control for Decision Support

Creating a Custom Control That Draws Itself

Defining a Custom Data Structure for Rendering

Coding a Data-Bound Custom Control

Defining the Custom Control Skeleton

Initializing and Updating the Data Bindings

Adding Bar Chart Instances to the Container

Adding Editing Support to a Custom Data Bound Control

Where Are We?

9 Implementing Custom Data-Bound Business Objects and Collections

Defining and Working with Data-Bound Business Objects

Defining and Working with Data-Bound Business Object Collections

.NET Framework Generic Collection Classes

The CustomBusinessObjects Example

Binding the Customers and Orders Objects to Form Controls

Generating Some Test Data to Bind Against

Setting the Textual Data-Binding Behavior of Custom Objects

Supporting Transacted Object Editing with IEditableObject

Supporting Object Edit Notifications with Property Change Events

Supporting Object Edit Notifications with INotifyPropertyChanged

Using BindingList<T> to Create Rich Object Collections

Creating a Custom Collection Type Based on BindingList<T>

Taking Over the Construction Process

Getting Some Test Data to Work With

Adding Search Functionality to the Collection

Adding Sorting Capabilities to the Collection

Managing Transacted Additions to a Collection

Raising Item Changed Events

Adding IBindingListView Functionality

Binding to Business Objects Through the Data Sources Window

Where Are We?

10 Validating Data Input and Handling Errors

Windows Forms Validation

Handling Validation Events

DataGridView Validation Events

Validation Up the Control Hierarchy

Displaying Validation Errors with the ErrorProvider Control

DataGridView Error Displays

DataGridView DataError Event

Controlling Validation Behavior with the AutoValidate Property

Validation down the Control Hierarchy

Extended Validation Controls

Capturing Data Errors on Data Sets

Providing Error Information from Custom Objects with IDataErrorInfo

Data Concurrency Resolution

Where Are We?

A Binding to Data in ASP.NET

ASP.NET Page Processing Basics

Data Binding in ASP.NET 1.X

Presenting Tabular Data in a Grid

Hooking Up Dynamic Behavior in a Code-Behind Class

Handling Row Selecting in the Grid

Using Data-Binding Expressions

Data-Binding Overview in ASP.NET 2.0

Data Sources

SqlDataSource Control

ObjectDataSource Control

AccessDataSource Control

XmlDataSource Control

SiteMapDataSource Control

Data-Binding Expressions

GridView Control

DetailsView Control

FormView Control

Master-Details Binding

Hierarchical Binding

Where Are We?

B Binding Data in WinFx Applications

WinFx UI Programming and Capabilities Overview

Writing a Simple WinFx Application

Getting Started with a “Hello World” Application

Building a Slightly More Involved Application

WinFx Data Binding 101

Data Contexts and Data Sources

What About XAML?

Binding a Collection to a Grid with Templates

Control Styling in WinFx

Where Are We?

C Programming Windows Forms Applications

Your First Windows Forms Data Application

Creating Windows Forms Applications with Visual Studio

Creating an Empty Windows Forms Project

Working with the Toolbox

Adding Members to the Form

Hooking Up an Event Handler and Data Binding

Windows Forms Designer-Generated Code (New in 2.0)

A Brief Tour of the Windows Forms Architecture

The Dawn of .NET Execution—The Main Method

Handling Control Events

Displaying Other Forms

Containing Forms Within a Parent Form

Common Data Display Controls

Label Controls

Button Controls

Check Box Controls

Radio Button Controls

Text Box Controls

RichTextBox Controls

DateTimePicker Controls

List Box Controls

Combo Box Controls

List View Controls

Tree View Controls

Picture Box Controls

Data Grid Controls

DataGridView Controls (New in 2.0)

Creating a Custom User Control

Laying Out Controls on a Form

Absolute Positioning and Sizing of Controls

Anchoring Controls

Docking Controls

Using Layout Container Controls (New in 2.0)

Setting Tab Order

Command and Control of Your Windows Forms Applications (New in 2.0)

Where Are We?

D Accessing Data with ADO.NET

Relational Data Access

The Ubiquitous DataSet

Loading Data Sets from a File

Creating a Data Set Programmatically

Loading Data Sets from a Database

Loading a DataTable with a DataReader

Master-Details DataSets

Retrieving Data with Stored Procedures

Updating the Database Using Data Sets

Handling Concurrency

Updating with Data Sets and Stored Procedures

Searching Data Sets

Merging Data from Multiple Data Sets

Working with Data Views

Working with Transactions

Scoping Transactions with System.Transactions

Client-Side Transactions

Data Set and Data Adapter Events

Reading Data into Business Objects

XML Data Access

Working with the XmlDataDocument Class

Working with the XPathDocument Class

Loading Data into an XPathDocument

Querying XML Data

Navigating an XML Document

Where Are We?

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.104.10