Practical Applications of Reflection
A common and practical application—binding properties to controls—uses Reflection behind the scenes. This works in Windows Forms and Web pages.
DataBinding.sln contains an example of user-defined type Customer and a place to store customers as well as a Contacts class that can contain an ArrayList of contacts. The ArrayList implements an interface called IList, which supports enumeration that allows us to bind controls directly to our objects. The sample application is shown in Figure 4.1.
Figure 4.1. A simple form bound directly to the shown TextBox controls by using Reflection and DataBindings.
The Customer ...
Get Visual Basic® .NET Power Coding 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.