O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

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

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

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