Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Binding in Depth DEV 419 Level 400 Eyal Vardi CEO Experts4D Microsoft VSTO MVP blog: www.eVardi.com.

Similar presentations


Presentation on theme: "Data Binding in Depth DEV 419 Level 400 Eyal Vardi CEO Experts4D Microsoft VSTO MVP blog: www.eVardi.com."— Presentation transcript:

1 Data Binding in Depth DEV 419 Level 400 Eyal Vardi CEO Experts4D Microsoft VSTO MVP blog: www.eVardi.com

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

3 Application Architecture Binding

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 SimpleBinding Label, TextBox, PictureBox, DateTimePicker ComplexBinding 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

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

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

10 Data Template

11 Binding Source

12 The Binding Flow BindingSource DataSet DataTable DataSource DataMember Simple Control Complex Control Column DataBinding Property DataSource BindingSource * Don’t forget to add default constructor

13 Closer look on BindingSource Control BindingSource Simple Binding Complex Binding CurrencyManager Control Data Source Binding Binding BindingContexBindingContex

14 BindingSource Class (Binding Contex)

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 BindingSource Class (Sort, Find & Filter)

17 Data Source & Interfaces

18 IEnumerable ICollection IList IBindingList.NET 1.x Interfaces

19 .NET 2.0 New Interface

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

21 Recipe… 1)Inherit BindingList<> 2)Add sort and search capability 3)Implement IBindingListView for getting advance sort and filter capability

22 .NET 1.x Interfaces

23 BindingListView<T>

24 Build Custom Data Source 2.Interfaces should be implemented in your custom type INotifyPropertyChangedIEditableObjectIDataErrorInfo

25 INotifyPropertyChanged INotifyPropertyChanged IEditableObject IEditableObject IDataErrorInfo IDataErrorInfo

26 New Feature in Binding 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 ControlDataSource Parse Event Format Event Binding

29 Type Conversion Custom data type to string, can be done: Custom data type to string, can be done: Override the ToString() Override the ToString() Use the Binding Format event Use the Binding Format event Write custom class for conversion Write custom class for conversion String to custom data type, can be done: String to custom data type, can be done: Use the Binding Parse event Use the Binding Parse event Write custom class for conversion 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! איך ממלאים משוב? ב - email בסוף כל יום ב -Beat Center מה מקבלים? חולצת Feel The Beat השתתפות בהגרלת כרטיסי טיסה מכשירי i-mate ועוד... (לממלאים משוב לכל יום) DEV419

35 Your potential. Our passion. TM


Download ppt "Data Binding in Depth DEV 419 Level 400 Eyal Vardi CEO Experts4D Microsoft VSTO MVP blog: www.eVardi.com."

Similar presentations


Ads by Google