Data Access: Using Custom Data Binding Handlers
This application demonstrates how to use the Format and Parse event
handlers when data binding Windows Form controls. The Format event fires
when the data is transferred from the data source to the bound
control, whereas the Parse event fires when data is moved back into
the data source. By handling each of these events you can display the data
in one format, but store it in another.
Featured Highlights
-
Data is loaded into a DataSet by creating a new Employees table (using SELECT
INTO) and then adding an additional column for some extra demo data.
-
Records can be stepped through with mouse clicks on the navigation buttons, or
by key presses (Left and Right arrow keys for Previous and Next, and Home and
End for First and Last records, respectively).
-
Data is formatted and parsed using custom data binding handlers. Numerous common
data conversion scenarios are demonstrated, such as handling dates, null
values, and Boolean values.
-
A DataGrid displays data from a second table in the DataSet by filtering a
DataView based on the current record's EmployeeID.
-
Changes made to the fields can be propagated back to the database by clicking
the Save button.
Requirements
This application requires the release version of Visual Studio .NET Professional
(or greater) and access to the Northwind database residing in SQL Server or the
Microsoft Data Engine (MSDE). To install MSDE, do the following:
1. Open the Start menu, click Programs, click Microsoft .NET
Framework SDK, and then click Samples and Quickstart Tutorials.
2. Click "Step 1: Install the .NET Framework Samples Database".
3. Open a command window, and CD to
\Samples\Setup This is typically : C:\Program Files\Microsoft
Visual Studio .NET\FrameworkSDK\Samples\Setup
4. Type: osql -E -S (local)\NetSDK -i InstNwnd.sql
Running the Sample
Simply Press F5.
See Also
Data Binding and Windows Forms