Chapter 10. Data Binding
Windows Forms lets us create rich user interfaces for viewing and
editing information. But these applications are often just frontends
to a larger system—the information they present typically
resides elsewhere. You would not want to entrust your
mission-critical data to the Text
property of a
TextBox
control, and so a great many Windows Forms
applications don’t own the information they
present—the master copy of the data will typically be inside a
database. Even applications that do not warrant the use of a
full-blown database will usually still maintain a distinction between
their internal representation of the data and the presentation of
that data.
To help us build applications that have cleanly separated data and presentation layers, the .NET Framework provides a facility called data binding. This is a remarkably flexible architecture for managing the connection between information sources and user interface elements. It provides full support for .NET’s data-access architecture, ADO.NET, but it is also extensible—it is simple to write your own data sources, and any control, including any user controls or custom controls that you write, can participate in the presentation of data.
In this chapter, we will start by examining simple data binding, which allows any source of information to be connected to any property of a control. We will then look at complex binding, which is the specialized support for more complex data sources offered by certain controls. ...
Get .NET Windows Forms in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.