Advertisement Jump to content
Sign in to follow this  

[.net] Dynamic Array of Custom Controls

This topic is 4933 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Everyone Again. What I'm trying to do, is make a custom control..then dynamically load a bunch of the (different amounts of them every time..the number of controls is dependent on a bunch of other things). My they don't show up..I'm trying to do it just like in the InitalizeComponent Function..but they still don't show..heres sorta what I got using c# here, and developing with 2005 beta express
   public Project.CustomControl[] ucControl;
   public void ShowControls(int controls)
            int x=0; int y=0; int w=10; int y=10;
            ucControl= new CustomControl[iCount];
            ucControl[1] = new CustomControl("this", "is", "sorta", "like", "my", "constructor");
            ucControl[1].Location = new Point(x, y);
            ucControl[1].Size = new Size(w, h);
            ucControl[1].Show(); //doesn't show..
            x+=100; y+=100;
            //next control

I realize that isn't much, but I thought I should just try to get one to show up before trying to load all of them. I think I might be able to figure this out by trial and error, but I kinda wanted to see if this is the suggested way to add a dynamic array of custom controls to an application. Also if it matters these controls will be inside a panel..(I think that means I have to do like a 'panel1.Add(ucControl)' and things like that) As always any help is appreciated, and I do rate people on how helpful they are..or kind/nice I suppose to.. Thanks Again, ArchG

Share this post

Link to post
Share on other sites
Have you added the controls to someone else's children?

ucControl[1] = new CustomControl(...);
// init ucControl

Edit: Oops, you mention something about adding to a panel, although your code doesn't do that.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!