Data Binding in Windows Forms - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Data Binding in Windows Forms

Description:

The IList interface does not include a concept of position. ASP.NET Web Forms allows binding to the DataReader object or the IEnumerable ... – PowerPoint PPT presentation

Number of Views:31
Avg rating:3.0/5.0
Slides: 13
Provided by: brenda117
Category:
Tags: ado | binding | data | forms | windows

less

Transcript and Presenter's Notes

Title: Data Binding in Windows Forms


1
Data Binding in Windows Forms
2
What can be bound
  • Windows Forms can bind to
  • the public properties of a class
  • any class that supports the IList interface
  • The IList interface does not include a concept of
    position.
  • ASP.NET Web Forms allows binding to the
    DataReader object or the IEnumerable interface
    because forward-only scrolling is acceptable

3
Binding Managers
  • The Windows Forms object model supports two
    different binding managers
  • PropertyManager, binds simple controls to public
    properties of a class.
  • CurrencyManager, binds simple or complex controls
    to an object that supports the IList interface

4
Binding Overview
Form
DataBindings
Control
BindingContext
Binding
ControlBindingsCollection
Binding
Binding
5
DataBindings
  • Maintains the ControlBindingsCollection, which
    holds Binding objects
  • Be consistent in binding expressions
  • Control1.DataBindings.Add(Text, ds, table1.X)
  • Control1.DataBindings.Add(Text, ds.table1, X)

6
Currency Manager
  • Has a one to one relationship with a data source
  • Created by form when first Binding is added
  • Maintains the current position in the list.
  • Exposes a PositionChanged event.
  • Ensures controls show data from the same record.

7
Binding Context
  • The forms BindingContext property
  • Is typed as base class BindingManagerBase
  • bc Me.BindingContext(ds, "Customers")
  • Needs to cast to correct derived type
  • CurrencyManager
  • Get the underlying bound collection from the List
    property.
  • cm CType(bc, CurrencyManager)
  • dv CType(cm.List, DataView)
  • al CType(cm.List, ArrayList)
  • PropertyManager
  • Get the underlying bound object from the Current
    property
  • pm CType(bc, PropertyManager)
  • MyObject CType(pm.Current, MyClass)

8
Binding to ADO.NET Data Objects
  • DataColumn object
  • You can simple-bind a control to a column within
    a data table. Each DataColumn object has a
    DataType property that determines the kind of
    data the column holds
  • DataTable object
  • When you bind to a DataTable, you are a really
    binding to the table's default view.
  • DataView object
  • A customized view of a single data table that may
    be filtered or sorted. A data view is the data
    "snapshot" used by complex-bound controls. You
    can simple- or complex-bind to the data within a
    data view, but be aware that you are binding to a
    fixed "picture" of the data rather than a clean,
    updating data source.
  • DataSet object
  • You are actually binding to the DataSet's default
    DataViewManager
  • DataViewManager object
  • A customized view of the entire DataSet,
    analogous to a DataView, but with relations
    included.

9
DataView
  • Typically the bound object
  • Use to change data programatically, not the UI
  • implements IBindingList
  • ListChangedEvent, notifies any user changes (such
    as additions, deletions, or sorting)

10
Table Styles
  • Can have multiple table styles, only one selected
    at a time.
  • Each table style can map to a different data
    source
  • Set the TableStyles MappingName at run time to
    select it.
  • TableStyle1.MappingName Table1
  • TableStyle2.MappingName

11
Table Style Columns
  • Custom column are needed to
  • handle columns that show a button, combobox or
    other control in the grid
  • set column read-only
  • special case formatting

12
  • Roadmap for Windows Forms Data Binding PSS ID
    Number 313482
  • George Shepherds Windows Forms FAQ
  • http//www.syncfusion.com/FAQ/WinForms/
  • BlueVision Publishing Books
  • http//www.akadia.com/services/dotnet_databinding.
    html
Write a Comment
User Comments (0)
About PowerShow.com