C#Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Is it possible to make controls arrays. In VB you can assign 2 pictureboxes the same name and thus making them an array, eg: picturebox[0] and picturebox[1]
Is that possible in c# (in design view)? or do you have to create them at runtime?
In .Net their is not concept like control array. But u can create array of controls by creating object of control class and assigning a particular type of control (like textbox) of the form to that control object.
In C#, you can make an array of any object. If you have a class called clsWidgets, you can make an array of these widgets by using the code...
clsWidgets[100] MyWidgets = new clsWidgets[];
If you do not know how many array elements you will be needing...
clsWidgets[] MyWidgets;
Then to initialize the array...
MyWidgets = (clsWidgets[])Array.CreateInstance(typeof(clsWidgets), 100);
Just replace the clsWidgets with your picturebox. I use the above formats all the time.