Data Binding in Windows Forms

Data Binding in Windows Forms PowerPoint PPT Presentation


  • 281 Views
  • Updated On :
  • Presentation posted in: General

What can be bound. Windows Forms can bind to the public properties of a classany class that supports the IList interfaceThe 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.

Download Presentation

Data Binding in Windows Forms

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


1. Data Binding in Windows Forms

2. Simple Data Binding Simple data binding is the ability of a control to bind to a single data element, such as a value in a column in a dataset table. This is the type of binding typical for controls such as a TextBox control or Label control — that is, a control that typically only displays a single value. In fact, any property on a control can be bound to a field in a database. For more information on simple data binding, see Creating a Simple-Bound Control on a Windows Form. Complex Data Binding Complex data binding is the ability of a control to bind to more than one data element, typically more than one record in a database, or to more than one of any other type of bindable data element. Examples of controls that support complex binding are the DataGrid, ListBox, and ErrorProvider controls. Simple Data Binding Simple data binding is the ability of a control to bind to a single data element, such as a value in a column in a dataset table. This is the type of binding typical for controls such as a TextBox control or Label control — that is, a control that typically only displays a single value. In fact, any property on a control can be bound to a field in a database. For more information on simple data binding, see Creating a Simple-Bound Control on a Windows Form. Complex Data Binding Complex data binding is the ability of a control to bind to more than one data element, typically more than one record in a database, or to more than one of any other type of bindable data element. Examples of controls that support complex binding are the DataGrid, ListBox, and ErrorProvider controls.

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

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 TableStyle’s 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 Shepherd’s Windows Forms FAQ http://www.syncfusion.com/FAQ/WinForms/ BlueVision Publishing – Books http://www.akadia.com/services/dotnet_databinding.html

  • Login