An array of custom controls

Posted on 2005-04-20
Medium Priority
Last Modified: 2010-04-16
Please see my screenshot:



As you can see I have a simple custom control.

I can place a bunch of these on the form.  That's okay..but it is not very dynamic.  The number is fixed.

But what I want is some kind of Container control that contains a bunch of these controls.

The number of custom controls inside the container control can increase or decrease at runtime.

It would go something like this:

//Drop the container control on the Form

//Behind the scenes it would be declared like this (for example....this would happen automatically)
CustControlContainer ccc = new CustControlContainer(  )

//Programmatically create custom controls to the Container

//This would add four controls...each one would take up a fourth of the space inside the Container control.

//This would delete 2 of the 4 controls.  The 2 remaining controls would resize in order to divide the available space in half.

//This would add 2 controls again...bringing the total number of controls back up to 4 controls...which would divide the Container control available space evenly.

I want to get this far....and then think about my next question.

I am not sure if this is exactly how the finished control will work...but it will get me started.



Question by:Tom Knowlton
LVL 10

Accepted Solution

smegghead earned 2000 total points
ID: 13839565
You could have another usercontrol, which has the following

private OriginalControl[] AllControls;

private void BuildScreen()
      foreach (OriginalControl oc in AllControls)
            oc.Location=new Point(...,...); // Work out where to draw it
            oc.Size=new Size(...,...); // You'll have to work out the best size depending on the area you are drawing inside
public void AddCells(int Num)
      // Expand the size of the array (i.e. create a new array of the required size, and copy the original one into the new one.. then set the old array=new array

Does this help ?


Author Comment

by:Tom Knowlton
ID: 13839684

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

807 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