O'Reilly logo

.NET Windows Forms in a Nutshell by Matthew Adams, Ian Griffiths

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required