How do you add a control to a usercontrol during design time? [modified]
-
I designed a user control to be a container for a layout. The control itself uses three other usercontrols for tabs and title and such. My control shows up in the toolbar and I can drag it to the form in the designer and set all of it's options but this usercontrol was designed to hold one or more usercontrols of any kind. I can add any item programmatically but if I drag a control over it in the designer it will not add the control I'm dragging to my usercontrol after I drop it on it. Any ideas how this functionality can be added for the designer? I am using Visual Studio 2008 Express - C#
modified on Thursday, September 4, 2008 11:46 PM
-
I designed a user control to be a container for a layout. The control itself uses three other usercontrols for tabs and title and such. My control shows up in the toolbar and I can drag it to the form in the designer and set all of it's options but this usercontrol was designed to hold one or more usercontrols of any kind. I can add any item programmatically but if I drag a control over it in the designer it will not add the control I'm dragging to my usercontrol after I drop it on it. Any ideas how this functionality can be added for the designer? I am using Visual Studio 2008 Express - C#
modified on Thursday, September 4, 2008 11:46 PM
I had that problem myself and I'm not sure what best to do. Maybe there is a trick we both don't know. If you don't have a user control, but a control derived from Panel, you can drop controls onto it at design time and they will be added. Also I think if you have a Panel on your user control, you can drop controls onto the Panel. So maybe you can just fill your user control with a Panel and go from there.
-
I designed a user control to be a container for a layout. The control itself uses three other usercontrols for tabs and title and such. My control shows up in the toolbar and I can drag it to the form in the designer and set all of it's options but this usercontrol was designed to hold one or more usercontrols of any kind. I can add any item programmatically but if I drag a control over it in the designer it will not add the control I'm dragging to my usercontrol after I drop it on it. Any ideas how this functionality can be added for the designer? I am using Visual Studio 2008 Express - C#
modified on Thursday, September 4, 2008 11:46 PM
Found something: read up on the ParentControlDesigner class http://msdn.microsoft.com/en-us/library/system.windows.forms.design.parentcontroldesigner(VS.71).aspx