1 / 34

Data Binding in Depth DEV 419 Level 400

Eyal Vardi CEO Experts4D Microsoft VSTO MVP blog: www.eVardi.com. Data Binding in Depth DEV 419 Level 400. Agenda. Data Binding Overview BindingSource Class Data Source & Interfaces Binding Class Improvement. Binding. Application Architecture. What Can we Bind?. Data Consumers.

Télécharger la présentation

Data Binding in Depth DEV 419 Level 400

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Eyal Vardi CEO Experts4DMicrosoft VSTO MVPblog: www.eVardi.com Data Binding in DepthDEV 419 Level 400

  2. Agenda • Data Binding Overview • BindingSource Class • Data Source & Interfaces • Binding Class Improvement

  3. Binding Application Architecture

  4. What Can we Bind? Data Consumers Data Providers Object You can only bind to the public properties One Way .NET ControlsSimple Binding ArrayList DataSet .NET ControlsComplex Binding Custom Collection Two Way Config File

  5. Simple Binding Label, TextBox, PictureBox, DateTimePicker Complex Binding DataGrid, ComboBox, ListBox

  6. 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

  7. Data Templates class Address { string Address {get;set} string City {get;set} string COuntry {get;set} string PostalCode {get;set} } User Control Data Template

  8. Customize Data Source Win • Need to implement one of the following data binding attributes: • DefaultBindingPropertyAttribute • ComplexBindingPropertiesAttribute • LookupBindingPropertiesAttribute

  9. Data Template

  10. Binding Source

  11. SimpleControl ComplexControl DataSource DataMember Property DataBinding Column DataTable DataSource BindingSource DataSet BindingSource The Binding Flow * Don’t forget to add default constructor

  12. Closer look on BindingSource BindingSource Control Data Source Simple Binding Binding CurrencyManager Control Binding Complex Binding BindingContex

  13. BindingSource Class (Binding Contex)

  14. ? 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

  15. BindingSource Class (Sort, Find & Filter)

  16. Data Source & Interfaces

  17. IEnumerable ICollection IList IBindingList .NET 1.x Interfaces

  18. .NET 2.0 New Interface

  19. Build Custom Data Source • Interfaces should be implemented in your custom collection • IBindingListView • Sort • Advanced Sort • Filter • Search

  20. Recipe… Inherit BindingList<> Add sort and search capability Implement IBindingListView for getting advance sort and filter capability

  21. BindingListView<T>

  22. Build Custom Data Source • Interfaces should be implemented in your custom type • INotifyPropertyChanged • IEditableObject • IDataErrorInfo

  23. INotifyPropertyChanged • IEditableObject • IDataErrorInfo

  24. New Feature in Binding Class • Update mode • Formatting data • Null Value • Error notification

  25. New Feature in Binding Class

  26. Custom Formatting & Parsing • We use theBinding 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 Binding Parse Event Format Event

  27. 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

  28. Custom Formatting & Type Converter

  29. DataSet Can’t Solve All your Problems

  30. Books www.izzybooks.com

  31. איך ממלאים משוב? ב - email בסוף כל יום ב -Beat Center מה מקבלים? חולצת Feel The Beat השתתפות בהגרלת כרטיסי טיסה מכשירי i-mate ועוד...(לממלאים משוב לכל יום) New York! New York! DEV419

  32. Your potential. Our passion. TM

More Related