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