[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to control array in C#

Posted on 2006-06-02
3
Medium Priority
?
252 Views
Last Modified: 2008-03-10
Hi Experts,

Is it pssible to create control array viz picture box, just like VB.


thanks in adance.
0
Comment
Question by:avinash_takale
3 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 16821269
you can create an Array of controls - in fact you cancreate an array of 'anything' - an array of Object

but this is NOT the same thing as a VB 6 style Control Array -  .NET does NOT support control arrays in the same way that VB 6 did.

AW
0
 
LVL 5

Expert Comment

by:aaronfeng
ID: 16821377
Do something like this:

// if you want array of buttons
Control[] controls = new Controls[10];
for(int i = 0; i < 10; i++) controls[i] = new Button();

Cheers,

Aaron
http://aaronfeng.blogspot.com/
0
 
LVL 2

Accepted Solution

by:
HeidarV earned 200 total points
ID: 16821985
Hello,
this is another way:

List<Control> myControls= new List<Control>();

void InsertControls(int controlCount)
{

this.SuspendLayout();
for (int i=0; i<controlCount; i++)
{
    PictureBox pictureBox = new PictureBox();
    // pictureBox.Location = ....
    // set other properties
   
    myControls.Add(pictureBox);
    this.Controls.Add(pictureBox);
}
this.ResumeLayout(false);

}
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month18 days, 11 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question