xsharp.eu • DotNet Controls - Page 2
Page 2 of 2

DotNet Controls

Posted: Thu Aug 10, 2023 1:07 pm
by robert
Karl,
The only thing that I think is wrong with this code is that you are still using an array.
Why not make it a List<System.Windows.Forms.Control> and why not use foreach to enumerate the list?
The array takes more memory than the List<>. The controls are stored in a usual and in the loop the controls are extracted from the usual, which at least requires a type check to see if the usual is indeed an object. Also, the runtime then has to check to see that the object returned from the usual is indeed a control.
If you declare the list like I suggested, then you can be certain that each element is a control.
FYI, the array class already uses a List<>, but that is a List<USUAL>.

Robert

Robert

DotNet Controls

Posted: Thu Aug 10, 2023 1:41 pm
by ecos
Hi Robert,

of course you are right, but right now if i do tests I'm still quicker with old VO-style.
I'll change that right now...

Karl

DotNet Controls

Posted: Fri Aug 11, 2023 4:44 am
by Chris
Hi Karl,

Ah, OK, I just thought a container control (I had been using a CustomControl from the VO toolbox) that has the winform control inside it makes things simpler with positioning it on the window, also makes it easier to have a visual clue in the window editor as to how it will look (position wise) at runtime. But especially with a toolstrip I guess indeed it makes more sense to put directly on the window.