Replace a Control Array
Problem
You want to provide the same functionality as a Visual Basic 6 control array in Visual Basic .NET.
Solution
Create an event handler that handles multiple controls, and examine the sender parameter to identify which control fired the event.
Discussion
It’s possible to create a control array in a Visual Basic .NET project by making heavy use of the VisualBasic.Compatibility namespace. However, there are other solutions using only native .NET features that are better performing, more elegant, and easier to manage than using these legacy features.
One of the easiest approaches is simply to handle multiple events with a single event handler. You can then determine which control fired the event by examining the sender event ...
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.