Control Arrays
-
And why is everyone so against them!!! I mean, every time I turn around, MS is throwing them out: Can't do them in VB.Net, couldn't do it (could hack it) in MFC, etc. What is the deal!!!
You dont need control arrays. In VB, they gave you the ability to write one event handler for a whole bunch of controls. With AddHandler in VB.NET (or using the += operator for events in C#) you can acheive the same thing, with the extra advantage that they dont even have to be the same type of controls, or the same events. The other thing it let you do in VB was to add controls at run time. In VB.NET and C# this is now even easier. Control arrays were an ugly way to do what .NET has made fairly elegant. -- David Wengier TAC ad gone wrong: "Don't fool yourself, you're a bloody idiot." Sonork ID: 100.14177 - Ch00k
-
But I want to be able to use loops when I'm working with my controls...drawing them for instance... An event isn't going to help me do that!
Thats what collections are good for :)
foreach( MyControl c in MyControlCollection ) { // use c }
James Sonork ID: 100.11138 - Hasaki "Smile your little smile, take some tea with me awhile. And every day we'll turn another page. Behind our glass we'll sit and look at our ever-open book, One brown mouse sitting in a cage." "One Brown Mouse" from Heavy Horses, Jethro Tull 1978 -
You dont need control arrays. In VB, they gave you the ability to write one event handler for a whole bunch of controls. With AddHandler in VB.NET (or using the += operator for events in C#) you can acheive the same thing, with the extra advantage that they dont even have to be the same type of controls, or the same events. The other thing it let you do in VB was to add controls at run time. In VB.NET and C# this is now even easier. Control arrays were an ugly way to do what .NET has made fairly elegant. -- David Wengier TAC ad gone wrong: "Don't fool yourself, you're a bloody idiot." Sonork ID: 100.14177 - Ch00k