all groups > dotnet compact framework > october 2004 >
You're in the

dotnet compact framework

group:

Control Arrays


Control Arrays Tim Boalch via .NET 247
10/31/2004 3:48:09 AM
dotnet compact framework:
More of a CLR issue, but WHY ON EARTH did they remove Control Arrays?

For example, in VB6, if u were making a dialog similar to the standard section of the Color Common Dialog, u'd have an array of PictureBoxes with different back-colours, and clicking on them would raise a single, common event:

Private Sub picColours_Click(Index as Integer)

MyChosenColour = picColours(Index).BackColor

End Sub

What could be more logical? It is...
- economic on code (no need to write practically identical event handlers for every single object)
- allows you to view-and-edit the objects in the form designer

Whereas now in VB.NET, you'd have to...
- create a object array
- create those objects dynamically at run-time (no ability to edit at design-time)
- put an AddHandler statement in Form_Load for every single one of those controls!


Fine, if you go into Add\Remove Toolbox Items, there is are things like "LabelArray" and "ButtonArray" - but how on earth are you supposed to use them?

--------------------------------
Tim Boalch

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

Re: Control Arrays Daniel Moth
10/31/2004 12:02:55 PM
Not sure if you are aware but choose to ignore the declarative way of
handling events in VB so I'll point it out:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dninvb02/html/ivb0102.asp

<quote>
You could create a subroutine that handles more than one event by adding a
comma-separated list of events, like so:
Handles txtOne.KeyPress, txtTwo.KeyPress
making a cheap replacement for Visual Basic's control array feature (which
..NET doesn't support).
</quote>

Cheers
Daniel

[quoted text, click to view]

AddThis Social Bookmark Button