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

Simple and Complex Binding

The examples we have seen so far all use the technique known as simple binding. Simple binding has two defining characteristics:

  • Bindings deal with single pieces of information, both in the sense that single source properties are bound to single control properties, and also in the sense that only a single item from a list can be shown at any one time.

  • Simple binding requires no special support from the control—the data-binding architecture is able to bind to any control property, including any new properties you introduce in your custom controls.

Complex binding overcomes the restrictions of simple binding—it can allow a single control to display multiple entries from a list, and multiple properties from any single item. However, it requires special support from the control—most of the built-in controls do not support complex binding, and if you want your own controls to support it, you will need to do most of the work yourself. But don’t be put off by the name—complex binding is only complex for the developer who creates the control; it can actually make things much simpler for developers who use the control.

The built-in controls that support complex binding are ListBox, ComboBox, and DataGrid. The first two work the same and we will start by looking at those. The DataGrid control’s data-binding support is rather more extensive, and we will examine it later.

List Control Binding

The ListBox and ComboBox controls have a great deal in common. They ...

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