Data Binding in Depth DEV 419 Level 400 Eyal Vardi CEO Experts4D Microsoft VSTO MVP blog: www.eVardi.com
Agenda Data Binding Overview BindingSource Class Data Source & Interfaces Binding Class Improvement
Application Architecture  Binding
What Can we Bind? One Way Two Way .NET Controls Simple Binding .NET Controls Complex Binding Data Consumers Data Providers Object ArrayList DataSet Custom Collection Config File You can  only  bind to the public properties
Simple   Binding Label, TextBox, PictureBox, DateTimePicker Complex  Binding DataGrid, ComboBox, ListBox
Data Binding Goals Run-Time: Binding  Data to Controls Synchronize  the data between the controls Formatting  and  Parsing  the data  Filter ,  Sort  and  Search  the data Design-Time: Simple and fast to implement
 
Data Templates Data Template class Address { string Address  {get;set} string City  {get;set} string COuntry  {get;set} string PostalCode {get;set} } User Control
Customize Data Source Win Need to implement one of the following data binding attributes: Default BindingPropertyAttribute Complex BindingPropertiesAttribute Lookup BindingPropertiesAttribute
Data Template
Binding Source
The Binding Flow * Don’t forget to add default constructor BindingSource DataSet DataTable DataSource DataMember Simple Control Complex Control Column DataBinding Property DataSource BindingSource
Closer look on BindingSource Control BindingSource Simple Binding Complex Binding CurrencyManager Control Data Source Binding Binding BindingContex
BindingSource Class (Binding Contex)
BindingSource.DataSource = Array =>  No  Add & Remove List<>  => Add & Remove TypOf  => Add & Remove new Object() => Add & Remove * BindingList<>  => Add & Remove DataView  => Add, Remove,    Sort, Search,   Filter *  Dervied Class can Support: Sort, Search and Filter ?
BindingSource Class (Sort, Find & Filter)
Data Source & Interfaces
IEnumerable  ICollection  IList  IBindingList .NET 1.x Interfaces
.NET 2.0 New Interface
Build Custom Data Source Interfaces should be implemented in your custom collection IBindingListView Sort Advanced Sort Filter Search
Recipe… Inherit BindingList<> Add  sort  and  search  capability Implement IBindingListView for getting  advance sort  and  filter  capability
.NET 1.x Interfaces
BindingListView<T>
Build Custom Data Source Interfaces should be implemented in your custom type INotifyPropertyChanged IEditableObject IDataErrorInfo
INotifyPropertyChanged IEditableObject IDataErrorInfo
New Feature in Binding Class Update mode Formatting data Null Value Error notification
New Feature in  Binding Class
Custom Formatting & Parsing We use the   Binding  class events: Format ,  raised when data is pushed from the data source into the control  Parse ,  raised when data is pushed from the control into the data source  Control Data Source Parse Event Format Event Binding
Type Conversion Custom data type to string, can be done: Override the  ToString() Use the Binding  Format  event Write custom class for conversion String to custom data type, can be done: Use the Binding  Parse  event Write custom class for conversion
Custom Formatting & Type Converter
DataSet Can’t  Solve All  your Problems
Books www. izzy books.com
 
New York! New York! איך ממלאים משוב ? ב  -  email   בסוף כל יום  ב  - Beat Center  מה מקבלים ? חולצת  Feel The Beat השתתפות בהגרלת כרטיסי טיסה מכשירי  i-mate   ועוד ... ( לממלאים משוב לכל יום ) DEV419
Your potential. Our passion.  TM

Data Binding In Depth

  • 1.
    Data Binding inDepth DEV 419 Level 400 Eyal Vardi CEO Experts4D Microsoft VSTO MVP blog: www.eVardi.com
  • 2.
    Agenda Data BindingOverview BindingSource Class Data Source & Interfaces Binding Class Improvement
  • 3.
  • 4.
    What Can weBind? One Way Two Way .NET Controls Simple Binding .NET Controls Complex Binding Data Consumers Data Providers Object ArrayList DataSet Custom Collection Config File You can only bind to the public properties
  • 5.
    Simple Binding Label, TextBox, PictureBox, DateTimePicker Complex Binding DataGrid, ComboBox, ListBox
  • 6.
    Data Binding GoalsRun-Time: Binding Data to Controls Synchronize the data between the controls Formatting and Parsing the data Filter , Sort and Search the data Design-Time: Simple and fast to implement
  • 7.
  • 8.
    Data Templates DataTemplate class Address { string Address {get;set} string City {get;set} string COuntry {get;set} string PostalCode {get;set} } User Control
  • 9.
    Customize Data SourceWin Need to implement one of the following data binding attributes: Default BindingPropertyAttribute Complex BindingPropertiesAttribute Lookup BindingPropertiesAttribute
  • 10.
  • 11.
  • 12.
    The Binding Flow* Don’t forget to add default constructor BindingSource DataSet DataTable DataSource DataMember Simple Control Complex Control Column DataBinding Property DataSource BindingSource
  • 13.
    Closer look onBindingSource Control BindingSource Simple Binding Complex Binding CurrencyManager Control Data Source Binding Binding BindingContex
  • 14.
  • 15.
    BindingSource.DataSource = Array=> No Add & Remove List<> => Add & Remove TypOf => Add & Remove new Object() => Add & Remove * BindingList<> => Add & Remove DataView => Add, Remove, Sort, Search, Filter * Dervied Class can Support: Sort, Search and Filter ?
  • 16.
  • 17.
    Data Source &Interfaces
  • 18.
    IEnumerable ICollection IList IBindingList .NET 1.x Interfaces
  • 19.
    .NET 2.0 NewInterface
  • 20.
    Build Custom DataSource Interfaces should be implemented in your custom collection IBindingListView Sort Advanced Sort Filter Search
  • 21.
    Recipe… Inherit BindingList<>Add sort and search capability Implement IBindingListView for getting advance sort and filter capability
  • 22.
  • 23.
  • 24.
    Build Custom DataSource Interfaces should be implemented in your custom type INotifyPropertyChanged IEditableObject IDataErrorInfo
  • 25.
  • 26.
    New Feature inBinding Class Update mode Formatting data Null Value Error notification
  • 27.
    New Feature in Binding Class
  • 28.
    Custom Formatting &Parsing We use the Binding class events: Format , raised when data is pushed from the data source into the control Parse , raised when data is pushed from the control into the data source Control Data Source Parse Event Format Event Binding
  • 29.
    Type Conversion Customdata type to string, can be done: Override the ToString() Use the Binding Format event Write custom class for conversion String to custom data type, can be done: Use the Binding Parse event Write custom class for conversion
  • 30.
    Custom Formatting &Type Converter
  • 31.
    DataSet Can’t Solve All your Problems
  • 32.
    Books www. izzybooks.com
  • 33.
  • 34.
    New York! NewYork! איך ממלאים משוב ? ב - email בסוף כל יום ב - Beat Center מה מקבלים ? חולצת Feel The Beat השתתפות בהגרלת כרטיסי טיסה מכשירי i-mate ועוד ... ( לממלאים משוב לכל יום ) DEV419
  • 35.