471,073 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

Design/Run Time User Control Container

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.
Jul 21 '05 #1
3 4890
Look in the InitializeComponent block of your form and see if the child
controls are added to the form's Controls collection.

They should be added to the container's Controls collection.

Here's a sample control that sounds similar in nature to yours:
Eric Cadwell
Jul 21 '05 #2
Hi Eric

Yes, the controls have been added to the component's
control collection in the InitializeComponent code block,
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

Jul 21 '05 #3
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.

public class UserControl4 : System.Windows.Forms.UserControl

public void RollUp()
this.Height = 24;

public void RollDown()
this.Height = 240;

Eric Cadwell
Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by rkbnair | last post: by
17 posts views Thread by tshad | last post: by
12 posts views Thread by Raed Sawalha | last post: by
3 posts views Thread by Nick Moore | last post: by
10 posts views Thread by Allan Ebdrup | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.