views:

31

answers:

2

in VB 6.0 we had used control arrays so we had only one method to take care of all those controls and we were passing "which control" to it. but now in C#, I did not use control arrays so if in VB 6.0 I had a array of size three controls now in C# I have three different control names...so kind of I am still using that method but the only thing that changes is the name of the controls because now I have three of them and I think it is ugly and redundant. with my current design is there a better way to take care of this?

+1  A: 

Your whole control structure is still available in C#, and you can walk the tree and store references to specific control types. You can also store references to dynamically created controls, if that's what you want.

I'm not aware of specialized control arrays in VB, so I'm not sure what functionality you're looking for, but what's stopping you from doing the same thing in C# that you did in VB?

Kendrick
Control arrays in VB6 were arrays of controls with the same name that was supported by the designer. It was also possible to dynamically resize the array at run time. Note that this can all still be done in c#. There is just no support in the form designer for it.
recursive
A: 

Hmm, I think I got it. It is just a matter of three method calls instead of one to that method. so previously if it was like this: SetupMethod(Control[i]) now I will have something like this: SetupMethod(Control1) .... SetupMethod(Control2) .... SetupMethod(Control3) ....

BDotA
If it's all in once place, there's nothing wrong with that. If you need that list more than once, you can create a list of controls (List<Control>) add things to it, then iterate through it in your SetupMethod.
Kendrick
Yep. I like this one: List Of Controls, pass it to that method and iterate through it. then I do not even need to call that method three times. thanks.
BDotA