Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Data Binding in Depth DEV 419 Level 400 Eyal Vardi CEO Experts4D Microsoft VSTO MVP blog: www.eVardi.com
Agenda <ul><li>Data Binding Overview </li></ul><ul><li>BindingSource Class </li></ul><ul><li>Data Source & Interfaces </li...
Application Architecture  Binding
What Can we Bind? One Way Two Way .NET Controls Simple Binding .NET Controls Complex Binding Data Consumers Data Providers...
Simple   Binding Label, TextBox, PictureBox, DateTimePicker Complex  Binding DataGrid, ComboBox, ListBox
Data Binding Goals <ul><li>Run-Time: </li></ul><ul><ul><li>Binding  Data to Controls </li></ul></ul><ul><ul><li>Synchroniz...
 
Data Templates Data Template class Address { string Address  {get;set} string City  {get;set} string COuntry  {get;set} st...
Customize Data Source Win <ul><li>Need to implement one of the following data binding attributes: </li></ul><ul><ul><li>De...
Data Template
Binding Source
The Binding Flow * Don’t forget to add default constructor BindingSource DataSet DataTable DataSource DataMember Simple Co...
Closer look on BindingSource Control BindingSource Simple Binding Complex Binding CurrencyManager Control Data Source Bind...
BindingSource Class (Binding Contex)
BindingSource.DataSource = <ul><li>Array =>  No  Add & Remove </li></ul><ul><li>List<>  => Add & Remove </li></ul><ul><li>...
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 <ul><li>Interfaces should be implemented in your custom collection </li></ul><ul><ul><li>IBinding...
Recipe… <ul><li>Inherit BindingList<> </li></ul><ul><li>Add  sort  and  search  capability </li></ul><ul><li>Implement IBi...
.NET 1.x Interfaces
BindingListView<T>
Build Custom Data Source <ul><li>Interfaces should be implemented in your custom type </li></ul><ul><ul><li>INotifyPropert...
<ul><ul><li>INotifyPropertyChanged </li></ul></ul><ul><ul><li>IEditableObject </li></ul></ul><ul><ul><li>IDataErrorInfo </...
New Feature in Binding Class <ul><li>Update mode </li></ul><ul><li>Formatting data </li></ul><ul><li>Null Value </li></ul>...
New Feature in  Binding Class
Custom Formatting & Parsing <ul><li>We use the   Binding  class events: </li></ul><ul><ul><li>Format ,  raised when data i...
Type Conversion <ul><ul><li>Custom data type to string, can be done: </li></ul></ul><ul><ul><ul><li>Override the  ToString...
Custom Formatting & Type Converter
DataSet Can’t  Solve All  your Problems
Books www. izzy books.com
 
New York! New York! <ul><li>איך ממלאים משוב ? </li></ul><ul><li>ב  -  email   בסוף כל יום  </li></ul><ul><li>ב  - Beat Cen...
Your potential. Our passion.  TM
Upcoming SlideShare
Loading in …5
×

Data Binding In Depth

2,432 views

Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Data Binding In Depth

  1. 1. Data Binding in Depth DEV 419 Level 400 Eyal Vardi CEO Experts4D Microsoft VSTO MVP blog: www.eVardi.com
  2. 2. Agenda <ul><li>Data Binding Overview </li></ul><ul><li>BindingSource Class </li></ul><ul><li>Data Source & Interfaces </li></ul><ul><li>Binding Class Improvement </li></ul>
  3. 3. Application Architecture Binding
  4. 4. 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
  5. 5. Simple Binding Label, TextBox, PictureBox, DateTimePicker Complex Binding DataGrid, ComboBox, ListBox
  6. 6. Data Binding Goals <ul><li>Run-Time: </li></ul><ul><ul><li>Binding Data to Controls </li></ul></ul><ul><ul><li>Synchronize the data between the controls </li></ul></ul><ul><ul><li>Formatting and Parsing the data </li></ul></ul><ul><ul><li>Filter , Sort and Search the data </li></ul></ul><ul><li>Design-Time: </li></ul><ul><ul><li>Simple and fast to implement </li></ul></ul>
  7. 8. Data Templates Data Template class Address { string Address {get;set} string City {get;set} string COuntry {get;set} string PostalCode {get;set} } User Control
  8. 9. Customize Data Source Win <ul><li>Need to implement one of the following data binding attributes: </li></ul><ul><ul><li>Default BindingPropertyAttribute </li></ul></ul><ul><ul><li>Complex BindingPropertiesAttribute </li></ul></ul><ul><ul><li>Lookup BindingPropertiesAttribute </li></ul></ul>
  9. 10. Data Template
  10. 11. Binding Source
  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
  12. 13. Closer look on BindingSource Control BindingSource Simple Binding Complex Binding CurrencyManager Control Data Source Binding Binding BindingContex
  13. 14. BindingSource Class (Binding Contex)
  14. 15. BindingSource.DataSource = <ul><li>Array => No Add & Remove </li></ul><ul><li>List<> => Add & Remove </li></ul><ul><li>TypOf => Add & Remove </li></ul><ul><li>new Object() => Add & Remove </li></ul><ul><li>* BindingList<> => Add & Remove </li></ul><ul><li>DataView => Add, Remove, Sort, Search, Filter </li></ul><ul><li>* Dervied Class can Support: </li></ul><ul><ul><li>Sort, Search and Filter </li></ul></ul>?
  15. 16. BindingSource Class (Sort, Find & Filter)
  16. 17. Data Source & Interfaces
  17. 18. IEnumerable ICollection IList IBindingList .NET 1.x Interfaces
  18. 19. .NET 2.0 New Interface
  19. 20. Build Custom Data Source <ul><li>Interfaces should be implemented in your custom collection </li></ul><ul><ul><li>IBindingListView </li></ul></ul><ul><ul><ul><li>Sort </li></ul></ul></ul><ul><ul><ul><li>Advanced Sort </li></ul></ul></ul><ul><ul><ul><li>Filter </li></ul></ul></ul><ul><ul><ul><li>Search </li></ul></ul></ul>
  20. 21. Recipe… <ul><li>Inherit BindingList<> </li></ul><ul><li>Add sort and search capability </li></ul><ul><li>Implement IBindingListView for getting advance sort and filter capability </li></ul>
  21. 22. .NET 1.x Interfaces
  22. 23. BindingListView<T>
  23. 24. Build Custom Data Source <ul><li>Interfaces should be implemented in your custom type </li></ul><ul><ul><li>INotifyPropertyChanged </li></ul></ul><ul><ul><li>IEditableObject </li></ul></ul><ul><ul><li>IDataErrorInfo </li></ul></ul>
  24. 25. <ul><ul><li>INotifyPropertyChanged </li></ul></ul><ul><ul><li>IEditableObject </li></ul></ul><ul><ul><li>IDataErrorInfo </li></ul></ul>
  25. 26. New Feature in Binding Class <ul><li>Update mode </li></ul><ul><li>Formatting data </li></ul><ul><li>Null Value </li></ul><ul><li>Error notification </li></ul>
  26. 27. New Feature in Binding Class
  27. 28. Custom Formatting & Parsing <ul><li>We use the Binding class events: </li></ul><ul><ul><li>Format , raised when data is pushed from the data source into the control </li></ul></ul><ul><ul><li>Parse , raised when data is pushed from the control into the data source </li></ul></ul>Control Data Source Parse Event Format Event Binding
  28. 29. Type Conversion <ul><ul><li>Custom data type to string, can be done: </li></ul></ul><ul><ul><ul><li>Override the ToString() </li></ul></ul></ul><ul><ul><ul><li>Use the Binding Format event </li></ul></ul></ul><ul><ul><ul><li>Write custom class for conversion </li></ul></ul></ul><ul><ul><li>String to custom data type, can be done: </li></ul></ul><ul><ul><ul><li>Use the Binding Parse event </li></ul></ul></ul><ul><ul><ul><li>Write custom class for conversion </li></ul></ul></ul>
  29. 30. Custom Formatting & Type Converter
  30. 31. DataSet Can’t Solve All your Problems
  31. 32. Books www. izzy books.com
  32. 34. New York! New York! <ul><li>איך ממלאים משוב ? </li></ul><ul><li>ב - email בסוף כל יום </li></ul><ul><li>ב - Beat Center </li></ul><ul><li>מה מקבלים ? </li></ul><ul><li>חולצת Feel The Beat </li></ul><ul><li>השתתפות בהגרלת כרטיסי טיסה </li></ul><ul><li>מכשירי i-mate ועוד ... ( לממלאים משוב לכל יום ) </li></ul>DEV419
  33. 35. Your potential. Our passion. TM

×