c# - Can we create a 1-D array of UserControl. ..? -


i created "usercontrol" in winforms- contains 1-button style.

and need use same array(10) , load form.

ex:  dim mybutton() button = new ucspecialbutton(dataset4category(i).tables(0).rows.count - 1) {} 

here usercontrol name ucspecialbutton

can create one-dimensional array of winform usercontrol.? 

with makkam's words: yes, can. guess you're uncertain whether can add dynamic number of controls form, because in designer cannot define arrays, drag , drop number of controls on form.

however, in fact visual studio generates code in background adds these controls collection. can write own code add arbitrary number of usercontrols collection dynamically. @ forms' .designer.cs file see how works.

taking makkam's array controls this, e.g.:

public myform() {     initializecomponent(); // call auto-generated code      // here add own code:     foreach (control control in controls)     {         this.controls.add(control); // how add control form.     } } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -