An array of custom controls

Please see my screenshot:

http://www.knowltonsoftware.com/junk/array_cust.gif

==========


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.
ccc.AddCells(4);


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

//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.
ccc.AddCells(2);



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.


Thanks!

Tom


LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
 
smeggheadConnect With a Mentor Commented:
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
      BuildScreen();
}

Does this help ?

Smg.
0
 
Tom KnowltonWeb developerAuthor Commented:
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.