By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,163 Members | 1,432 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,163 IT Pros & Developers. It's quick & easy.

Dropping controls in a User Control ges added to parent control

P: n/a
Joe
Hello all,

When I drop a control (say a Button) on my user control, the button is added
to the parent control of my user control and not my control. For example if
my user control is on a panel and a drop a button on it, the button is added
to the panel.Controls. I tried Bring to Front but it didn't make a
difference.

What am I doing wrong?

-Joe
Mar 27 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

I have seen lots of strange behaviour with the design viewer when working
with a lot of panels.
Please add the button in code.

userControl.Controls.Add(Your_button_here);
Regards,
Lars-Inge Tønnessen
Mar 27 '06 #2

P: n/a
AFAIK, the UserControl is not intended to be a container at design-time when
placed on a Form. In other words, the UserControl acts as a container when
you're designing the UserControl itself; however, it acts as a normal
control when dropped onto the design surface of a Form. So what is happening
in your situation is that you're attempting to add the Button to the
UserControl, which is not acting as a container, and so the Button will be
added as a sibling to the UserControl within the parent. You can change this
behavior by specifying the ParentControlDesigner class as the Designer to
use for your custom UserControl.
http://msdn2.microsoft.com/en-us/lib...ldesigner.aspx

--
Tim Wilson
..NET Compact Framework MVP

"Joe" <jb*******@noemail.noemail> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Hello all,

When I drop a control (say a Button) on my user control, the button is added to the parent control of my user control and not my control. For example if my user control is on a panel and a drop a button on it, the button is added to the panel.Controls. I tried Bring to Front but it didn't make a
difference.

What am I doing wrong?

-Joe

Mar 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.