DotNet Controls

This forum is meant for questions and discussions about the X# language and tools
User avatar
robert
Posts: 4518
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

DotNet Controls

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
ecos
Posts: 103
Joined: Tue Nov 10, 2015 6:49 am
Location: Germany

DotNet Controls

Post 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
User avatar
Chris
Posts: 4898
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

DotNet Controls

Post 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.
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply