Design/Run Time User Control Container

N

Nick Moore

This may be the wrong newsgroup for this question. I'm
trying to develop a container control inherited from a
panel that I can 'Roll Up' and 'Roll down' on a button
click. The component is to be available from the
toolbox. The first time I dragged the control from the
toolbox onto a form and added other toolbox components to
it in design mode, it obviously wasn't a container, the
other components were not associated with my control. I
found a KB article, 813450, which told me how to rectify
this, which mad my component a container at design time.
The problem now is that at run time the component is not
a container, when I roll it up, the components that I'd
dropped onto it at design time are left behind on the
main form. Anyone know what I'm doing wrong? Thanks.
 
G

Guest

Hi Eric

Yes, the controls have been added to the component's
control collection in the InitializeComponent code block,
this.panel1.Controls.Add(this.button1);
this.panel1.Controls.Add(this.lblCaption);
this.panel1.Controls.Add(this.pbxIcon);
this.panel1.Controls.Add(this.dividerPanel1);
and it still doesn't work, the dropped controls are there
in the component at design time, I can move the component
around on my test form and they all move together but
they're behind my component's panel ant run time.

I'll have a look at the CodeCentral example you mentioned
and see if that helps.

Thanks again

Nick
 
E

Eric Cadwell

panel1 is the instance name of your custom container control?

Try moving the container after you roll it up. Or change the backColor of
the container so that you can see it against the background of the form.
Your roll up code may not be doing what you expected.

[Designer(typeof(ParentControlDesigner))]
public class UserControl4 : System.Windows.Forms.UserControl
{

public void RollUp()
{
this.Height = 24;
}

public void RollDown()
{
this.Height = 240;
}
}

HTH;
Eric Cadwell
http://www.origincontrols.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top