Container control resizing issue (child not anchored)

G

Guest

I'm working with VS2005 on a Windows 2000 workstation, and I'm trying to
create a container control for use with win forms. I've started out by
creating a UserControl and adding the Designer attribute;
ParentControlDesigner (according to
http://support.microsoft.com/default.aspx?scid=kb;EN-US;322222).

I've placed a panel on my UserControl, and anchored its top, left, and right
sides; to appear as a titlebar. I've created an instance of my UserControl
on a Form and anchored it's top, left, and right sides as well.

I noticed when I execute my application, and resize the Form, the right-side
anchor of the panel (the UserControl's child) temporarily loses hold. I say
this, because a gap appears between the right edge of the Panel and the
right-edge of the UserControl. However, if I then resize the form, the
UserControl resizes and the Panel resizes with the gap remaining.

Does this make sense? Has anyone experienced this, and found a resolution?
 
G

Guest

I forgot to add that this problem occurs after I place a control onto my
UserControl when using my UserControl as a compiled control (not when
designing my UserControl).

Here are the steps to help clarify:

1. Create a new UserControl and, in it's designer, place a panel with
anchored edges

2. Compile the project and drop an instance of the UserControl onto a Form
(setting the UserControl's anchor property).

3. Add a control (i.e. Label control) onto the UserControl and run the
application
 
G

Guest

I found a workaround... an old technique from my VB6 programming days. I've
assigned the width of my CustomControl to the Panel within it on the Resize
event; effectively, manually anchoring the control at runtime.
 

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