mtelligent

View Original

Exam 70-553 - Implement data-bound controls.

Section 3

  • Part 2

    Integrating Data in a Windows Forms Application

    • Topic 1

Implement data-bound controls.

  • Use the DataGridView control to display and update the tabular data contained in a data source.
  • Use a simple data-bound control to display a single data element on a Windows Form.
  • Implement complex data binding to integrate data from multiple sources.
  • Navigate forward and backward through records in a DataSet in Windows Forms.
  • Define a data source by using a DataConnector component.
  • Create data forms by using the Data Form Wizard.

Summary

The DataGridView Control is new to .Net 2.0 and is meant as a replacement for the DataGrid Control. The DataGridView supports more column types out of the box () as compared to the DataGrid. The DataGridView Control can also display unbound data. Besides this the DataGridView offers many more ways to customize the appearance and feel of the data (Freezing Rows, hide rows, cols, provide tool tips, etc).

The next two paragraphs are an excerpt from the DataBinding FAQ listed in the resources and explain the concepts of Simple Data Binding and Complex Data Binding.

Simple binding is a general way to bind a property on a user interface element (Control) to a property on an instance of a type (object). For example, if a developer had an instance of a Customer type they could bind the Customer “Name” property to the “Text” property of a TextBox. When “binding” these two properties, changes to the TextBox.Text property will be propagated to the Customer.Name property and changes to the Customer.Name property will be propagated to the TextBox.Text property. Windows Forms simple binding supports binding to any public or internal .NET Framework property

Complex binding is a way to bind a list based user interface element (e.g. ComboBox, Grid) to a list of data instances (e.g. DataTable). Like simple binding, complex binding is generally two-way in that changes to the user interface element are propagated to the data list and changes to the data list are propagated to the user interface element. Windows Forms complex binding supports binding to data lists that support the IList interface (or IEnumerable when using a BindingSource component).

The DataSet in .Net 2.0 has been revamped a bit. They have improved indexing which should improve performance for large dataset operations. The Dataset also has a new property, RemotingFormat which can be set between SerializationFormat.Binary and SerializationFormat.Xml. Setting it to Binary will significantly increase transfer performance. Besides these performance features, the DataSet now has a GetTableReader Method which returns a DataReader that acts against the disconnected data in the dataset.

The DataConnector Component is a new component to .Net 2.0 that allows you to define a custom type as a datasource. You can then easily databind other databindable controls to the dataconnector.

Other Resources & Links:

DataGridView Control Overview
http://msdn2.microsoft.com/en-us/library/k39d6s23.aspx

DataGridView FAQ
http://www.windowsforms.net/TrackViews.aspx?ID=220&Type=Samples&Redir=%2fSamples%2fdownload.aspx%3fPageId%3d1%26ItemId%3d220%26tabindex%3d4

Visual Studio 2005 Windows Forms DataBinding FAQ
http://www.windowsforms.net/TrackViews.aspx?ID=206&Type=Samples&Redir=%2fSamples%2fdownload.aspx%3fPageId%3d1%26ItemId%3d206%26tabindex%3d4

New DataSet Features in ADO.NET 2.0
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/datasetenhance.asp