Download presentation
Presentation is loading. Please wait.
Published byAnnabel Booth Modified over 9 years ago
1
Making the Most of WinForms 2.0 Data Binding Rajiv Sodhi Microsoft India
2
Agenda Introduction to Data Binding New Objects and Enhancements Master-Detail Data Binding Object Data Binding
3
Data Sources Window Drag and drop operations Dragging/dropping tables from Data Sources Window onto form will create instances of: DataSet, TableAdapter, BindingSource BindingNavigator with nav/add/delete/save controls Bound control(s) Use Data Sources window to configure: Whether table will be edited with DataGridView or “Details” mode (individual controls) Mapping of detail control types to column data types (shortcut to Windows Forms Designer/Data UI Customization node in Options dialog)
4
Data Source Options Database (DataSet) Any ADO.NET data source Web Service Web Service Bind to parameterized methods of a Web service, for select, update, delete, and insert operations Object Object Bind to instances of classes and their properties (more later!)
5
Smart Defaults Control names Label captions Controlling through Caption property of Column objects in typed DataSets Automatic addition of typed DataSets and their DataTables to toolbox
6
Data Sources Window - Drag and Drop Completely Customizable Changing existing binding Establishing list/lookup binding DisplayMemberValueMemberSelectedValue Use of SmartTag More Smart Defaults
7
Drag and Drop Binding Data Sources Window Drag and Drop Data Binding Binding Controls
8
Agenda Introduction to Data Binding New Objects and Enhancements Master-Detail Data Binding Object Data Binding
9
WinForms 2.0 Data Binding Introduction to Objects Typed DataSet DataTable, TableAdapter BindingSource[BindingNavigator]
10
Strongly-Typed DataSets As before Consist of DataTables, Relations, Constraints Drag/drop from Server Explorer is supported Based on XML schema and code-behind class Also consists of TableAdapters Encapsulate a DataAdapter and a Connection Enhanced Typed Dataset Designer Instead of XSD Designer earlier Partial class support
11
TableAdapters Have Queries (methods for handling selects, updates, inserts, deletes) Queries exists as methods Fully customizable and extendable Can be re-used across multiple forms Have Connection property Connection string typically stored in web/app.config; default value applied in WinForms apps.
12
BindingSource: Basics Acts as “broker” between bound controls and actual data source DataSource, DataMember Point to typed DataSet, DataTable AllowEdit, AllowNew, AllowRemove Filter, Sort properties Run time: RemoveFilter, RemoveSort methods
13
BindingSource Run time members MovePrevious, MoveNext, MoveFirst, MoveLast, Position, Count properties (handles all navigation) AddNew, Insert(index, obj) methods RemoveCurrent, RemoveAt(index), Remove(obj) EndEdit, CancelEdit methods Works with edits and inserts/new’s Use of most of these is optional due to…
14
BindingNavigator UI provider that wraps navigation and maintenance functionality of BindingSource Not like old VB data control Has UI component Specialized toolstrip Has tray component too Selecting one will select both Members that associate ToolStrip controls with specific actors DeleteItem = bindingNavigatorDeleteItem (ToolStripButton)
15
How It All Connects BindingSource DataSet DataTable DataSource DataMember Simple Control Complex Control Column DataBinding Property Changes control contents via navigation, maintenance BindingNavigator BindingSource DataSource
16
Complex and Simple Binding Scenarios Complex Binding DataGridView.DataSource = BindingSource SimpleBinding TextBox.Text (and other controls/string-based properties) bound to member of BindingSource BindingNavigator.BindingSource = BindingSource
17
Introducing New Objects Typed Dataset Designer Customizable Typed TableAdapter Complex Binding Scenario Simple Binding Scenario
18
Agenda Introduction to Data Binding New Objects and Enhancements Master-Detail Data Binding Object Data Binding
19
Master-Detail Scenarios Binding to child rows Use of Typed DataSet Relations/Foreign Keys as data sources Precision drag & drop techniques Drop the child table, not the sibling
20
Master-Detail Binding
21
Agenda Introduction to Data Binding New Objects and Enhancements Master-Detail Data Binding Object Data Binding
22
Object Binding Binding to single objects Binding to BindingList Binding to BindingList AllowNew scenarios: AddingNew events on BindingSource and BindingList AllowNew scenarios: AddingNew events on BindingSource and BindingList Support for master-detail binding
23
Object Binding
24
Resources MSDN Smart Client Developer Center: http://msdn.microsoft.com/smartclient/ http://msdn.microsoft.com/smartclient/ Soup to Nuts: Build Windows Forms Applications with.NET (Webcasts and Virtual Labs): http://www.microsoft.com/events/series/windowsforms.mspx WindowForms.NET Whidbey Page: http://windowsforms.net/Default.aspx?tabindex=5&tabid=60 Improved Data Support Page: http://windowsforms.net/WhidbeyFeatures/default.aspx?PageID =2&ItemID=8&Cat=Runtime&tabindex=5 Newgroups: microsoft.public.dotnet.framework.windowsforms microsoft.public.dotnet.framework.windowsforms comp.lang.basic.visual.misc
25
© 2005 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.