Synchronize Controls on a Form

Problem

You want to create a record-browser where all control values are updated automatically for the current record.

Solution

Use a custom class to encapsulate the data, add instances of it to an ArrayList collection, and use .NET data binding.

Discussion

.NET data binding is most commonly used in ADO.NET applications, where you need to display one or more records in a DataTable. However, it can be used just as easily in other types of applications by replacing the DataTable or DataSet with a collection of custom objects.

For example, consider an example where you want to use multiple controls to show different pieces of information about a person. The person information is wrapped into a dedicated class, which is shown ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.