Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
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
 
Old May 21st, 2006, 03:06 AM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default PictureBox array ?

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?

 
Old May 24th, 2006, 06:17 AM
Friend of Wrox
 
Join Date: May 2006
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.


Bijgupt
 
Old May 26th, 2006, 12:49 PM
Registered User
 
Join Date: May 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Happy coding...







Similar Threads
Thread Thread Starter Forum Replies Last Post
about picturebox inherit youtubeline C# 3 December 12th, 2008 03:41 PM
Dynamic picturebox array thomaz C# 3 September 17th, 2008 01:15 PM
Picturebox Array? thomaz C# 2008 aka C# 3.0 1 September 12th, 2008 12:11 PM
Picturebox question julz127 Visual Basic 2005 Basics 0 February 26th, 2008 02:44 AM
Name of image in PictureBox purefan Beginning VB 6 5 November 27th, 2006 02:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.